this is my program and in the def show_flashcard part the program seems to be ignoring my if statement to see if the random word and the users input match

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

# Starter file for TM112 2022J TMA03 Q2


"""
This flashcard program allows the user to ask for a word_list entry.
In response, the program randomly picks an entry from all word_list
entries. It shows the entry. then asks the user to put in the English translation
Aif the users answer is correct correct will be printed on screen if is wrong
incorrect and the correct answer will be printed on screen
The user can repeatedly ask for an entry and also
has the option to quit the program instead of seeing
another entry.
"""

from random import *

# 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. then asks the user to put in the English translation
if the users answer is correct, correct will be printed on screen if is wrong
incorrect and the correct answer will be printed on screen  """

    
    random_key = choice(list(word_list))
    
    user_answer = input(f"What is the French equivalent of {random_key} ? ")
    if user_answer == random_key:
        print("Correct!")
    else:
        print(f"Incorrect. The correct answer is {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 my program and in the def show_flashcard part the program seems to be ignoring my if statement to see if the random word and the users input match

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY