The underlined sentences are what I'm having trouble adding in my code, I do know how to typecast numbers, but I don't know when in my code to do it.
gamblers = input().split()
winnings = 0
winnums = ('10','11','8','1','5','20')
lim = len(gamblers)
for num in gamblers:
if num in winnums:
winnings =100
if lim == 7:
if winnings > 0:
print(f"{gamblers[0]} won {winnings} pesos!")
if winnings == 0:
print (f"{gamblers[0]} won nothing!")
else:
print("Should be 6 numbers")
CodePudding user response:
To convert your inputs into a name and 6 numbers try:
name = gamblers[0]
lotto_numbers = [int(x) for x in gamblers[1:]]
Note that this is a bit fragile in the sense that numbers that don't cast to int
will throw an exception.
To test if you have 6 unique integers in that list you can:
duplicates_found = (len(lotto_numbers) != len(set(lotto_numbers)))
Casting to a set()
will remove duplicates and hopefully after the cast we have the same number of numbers as we started with.