Here is my code.
players = []
while len(players) >= 0:
name = input('Enter a name: ')
players.append(name)
if name == '':
players.pop()
break
else:
pass
player_dict = {name: [] for name in players}
print(player_dict)
for name in player_dict:
answer = input(name + ', who will win the fight? ')
player_dict[name].append(answer)
fight_winner = input('Who won the fight? ')
for name in player_dict:
if answer == fight_winner:
print(name + ' = Correct')
else:
print(name + ' = Incorrect')
print(player_dict)
This is what I see when I run the code
Enter a name: bill
Enter a name: bob
Enter a name:
{'bill': [], 'bob': []}
bill, who will win the fight? red
bob, who will win the fight? blue
Who won the fight? red
bill = Incorrect
bob = Incorrect
{'bill': ['red'], 'bob': ['blue']}
I would expect to see bill = Correct. How can I access each indivuals value and run it through an if statement? Thank you for any help
Aucun commentaire:
Enregistrer un commentaire