I start learning Python by myself, I googled around but I can not find the solution,
This is practice of lottery code and I would like to ask User couple of question. It is still practicing.
I try to build "add_players()" part.
So, My code is right now
user_players = set()
lottery_numbers = {13, 21, 22, 5, 8}
def menu():
user_input = input("ADD,SHOW,ROLL or QUIT ")
user_input=user_input.upper()
while user_input != 'QUIT':
if user_input == 'ADD':
add_players()
#elif user_input == 'SHOW':
# show_players()
elif user_input == 'ROLL':
roll()
else:
print('Done bye')
user_input = input("ADD,SHOW,ROLL or QUIT ")
def add_players():
name_input = input('Name?: ')
numbers_input = int(input('number?: '))
new_users = user_players.add(
{
'name': name_input,
'numbers': numbers_input
}
)
def roll():
for i in new_users:
Matched1 = i['numbers'].intersection(lottery_numbers)
print("{} matched {} ".format(i['name'], Matched1))
menu()
So when a user chose "ADD",
I would like to add values to my SET
which is this logic
def add_players():
name_input = input('Name?: ')
numbers_input = int(input('number?: '))
new_users = user_players.add(
{
'name': name_input,
'numbers': numbers_input
}
)
for example,
John 1,2,3,4,5
I know I should use add function, but
I am missing this part
new_users = user_players.add(
{
'name': name_input,
'numbers': numbers_input
}
)
How can I change my code to add players and their numbers? so when user choose "ROLL", It shows like "John matched 5"