34 lines
862 B
Python
34 lines
862 B
Python
|
def smallify_words(objects):
|
||
|
return [string.lower() for string in objects]
|
||
|
|
||
|
def get_5_objects():
|
||
|
while True:
|
||
|
try:
|
||
|
answer = input('Enter five objects separated by \';\': ').split(';')
|
||
|
assert len(answer) == 5
|
||
|
return answer
|
||
|
except AssertionError:
|
||
|
print(f'You were supposed to enter five objects, not {len(answer)}. Try again.')
|
||
|
|
||
|
def play_game():
|
||
|
objects = get_5_objects()
|
||
|
answer = input('What is your guess? ')
|
||
|
while True:
|
||
|
if answer == 'quit':
|
||
|
exit(0)
|
||
|
|
||
|
if answer in smallify_words(objects):
|
||
|
print(f'Congratulations! You remembered {answer}')
|
||
|
objects.remove(answer)
|
||
|
else:
|
||
|
print('Sorry, that was not one of the words')
|
||
|
|
||
|
if len(objects) == 0:
|
||
|
print('You did it! You remembered all the objects')
|
||
|
exit(0)
|
||
|
|
||
|
answer = input('What is your next guess? ').lower()
|
||
|
play_game()
|
||
|
|
||
|
|