Feb-24-2022, 06:24 PM
(This post was last modified: Feb-24-2022, 06:24 PM by deanhystad.)
numberInput[0] was probably supposed to be some kind of ID, maybe even a name. I think the purpose of the code is to enter some form of ID and 6 numbers.
I would put the "verify input" in a function. This code loops until the user enters valid input.
I would put the "verify input" in a function. This code loops until the user enters valid input.
winning_numbers = {10, 11, 8, 1, 5, 20} def get_info(): """Input name and 6 unique lottery number choices""" name = input("Enter you name: ") while True: numbers = input("Enter your 6 lottery numbers separated by spaces: ").split() if len(numbers) != 6: print("Should be 6 Numbers") continue if len(set(numbers)) != 6: print("There can be no duplicates") continue # Convert the numbers to integers try: numbers = list(map(int, numbers)) except ValueError: print("Numbers must be integers") continue return name, numbers name, entered_numbers = get_info() prize = len(winning_numbers & set(entered_numbers)) * 100 if prize > 0: print(name, "won", prize ,"pesos!") else: print(name, "won nothing!")