Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mport random
- bingo_table = [
- [1, 2, 3, 4, 5],
- [6, 7, 8, 9, 10],
- [11, 12, 13, 14, 15],
- [16, 17, 18, 19, 20],
- [21, 22, 23, 24, 25]
- ]
- def main():
- welcome_goodbye("Välkommen till Bingo!")
- while True:
- print_menu()
- user_choice = input("Val: ")
- if user_choice == "1":
- user_input = enter_number()
- random_list = random_ten()
- bingo_game(random_list)
- bingo_result(random_list, user_input)
- elif user_choice == "2":
- pass
- elif user_choice == "3":
- welcome_goodbye("God jul och gott nytt år!")
- break
- else:
- print("Vad god ange 1, 2 eller 3 som svar!")
- def enter_number():
- while True:
- user_input = input("Ange 5 siffror (mellan 1-25). Avgränsa med , : ").split(",")
- user_input = [int(i) for i in user_input]
- if number_len_check(user_input) == True:
- if number_size_check(user_input) == True:
- if duplicate_check(user_input) == True:
- return user_input
- else:
- print("Du får inte skriva in dubbletter!")
- else:
- print("Var god skriv in siffror mellan 1-26!")
- else:
- print("Du får bara gissa på 5 siffror!")
- def statistics():
- statistic_list = []
- statistics.append({"Spel 1":})
- def bingo_game(random_list):
- for row in bingo_table:
- for numbers in row:
- if numbers in random_list:
- print("[" + str(numbers), end="]")
- else:
- print(numbers, end=" ")
- print("")
- def bingo_result(random_list, user_input):
- result_list = []
- for numbers in user_input:
- if numbers in random_list:
- result_list.append(numbers)
- spacer()
- print("Antal rätt: " , len(result_list))
- def random_ten():
- return random.sample(range(1, 26), 10)
- def number_len_check(user_input):
- if len(user_input) == 5:
- return True
- else:
- return False
- def number_size_check(user_input):
- for nr in user_input:
- if nr in range(1,26):
- pass
- else:
- return False
- return True
- def duplicate_check(user_input):
- if len(user_input) == len(set(user_input)):
- return True
- else:
- return False
- def print_menu():
- print("1 | Spela Bingo")
- print("2 | Visa statestik")
- print("3 | Avsluta")
- def welcome_goodbye(prompt):
- print("═"*30)
- print(prompt)
- print("═"*30)
- return
- def spacer():
- """En 'Spacer-funktion' som gör texten lättare att läsa med mindre kod"""
- print("═"*45)
- main()
- #För VG, namge spelare tex 1. Sedan gör texikon eller neslad lista.
- #lexikon med spelare som nycklar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement