This is the program i have been given. I have to change it to meet the following criteria but can only change the body of the show_flashcard function # IMPORTANT # Q2 (a)(iii) Make changes only to # -- the docstring for the program as a whole. # -- the docstring of the show_flashcard() function # -- the body of the show_flashcard() function. def show_flashcard(): """ Show the user a random key and ask them to define it. Show the definition when the user presses return. """ random_key = choice(list(word_list)) print('Define: ', random_key) input('Press return to see the definition') print(word_list[random_key]) # Set up the word_list word_list = {'black':'noir', 'red':'rouge', 'yellow':'jaune', 'orange':'orange', 'white':'blanc', 'green':'vert'} # The interactive loop exit = False while not exit: user_input = input('Enter s to show a flashcard and q to quit: ') if user_input == 'q': exit = True elif user_input == 's': show_flashcard() else: print('You need to enter either q or s.')
This is the
I have to change it to meet the following criteria but can only change the body of the show_flashcard function
# IMPORTANT
# Q2 (a)(iii) Make changes only to
# -- the docstring for the program as a whole.
# -- the docstring of the show_flashcard() function
# -- the body of the show_flashcard() function.
def show_flashcard():
""" Show the user a random key and ask them
to define it. Show the definition
when the user presses return.
"""
random_key = choice(list(word_list))
print('Define: ', random_key)
input('Press return to see the definition')
print(word_list[random_key])
# Set up the word_list
word_list = {'black':'noir',
'red':'rouge',
'yellow':'jaune',
'orange':'orange',
'white':'blanc',
'green':'vert'}
# The interactive loop
exit = False
while not exit:
user_input = input('Enter s to show a flashcard and q to quit: ')
if user_input == 'q':
exit = True
elif user_input == 's':
show_flashcard()
else:
print('You need to enter either q or s.')
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images