import random
participants = ['Jack','Jill','Larry','Tom']
def Guess(participants):
my_participant_dict = {}
for participant in participants:
my_participant_dict[participant] = random.randint(1, 9)
if my_participant_dict['Larry'] == 9:
return True
else:
return False
print(Guess(participants))
Asked
Active
Viewed 860 times
-4

Robert
- 7,394
- 40
- 45
- 64
-
31) Code formatting is important. 2) What is your actual question? I strongly recommend you read the [help section of the site](https://stackoverflow.com/help) for guidance on both how to ask and how to answer questions on stackoverflow. – pjs May 26 '21 at 20:44
1 Answers
0
# Revised Guess() function
def Guess(participants):
my_participant_dict = {}
for participant in participants:
my_participant_dict[participant] = random.randint(1, 9)
try:
if my_participant_dict['Larry'] == 9:
return True
except KeyError:
return None
else:
return False

StupidWolf
- 45,075
- 17
- 40
- 72