Q:

Creating a "Flashcard" vocabulary program

I'd like to make a program in Python 3 that would be essentially vocabulary flashcards. I'd be able to list the terms, add a term, or display a random definition to try and accurately guess. Once guessed accurately, I would be given the option for another definition to guess. Alternatively, I'd like to just be able to display a random key:value pair, and to continue viewing pairs until I enter EXIT.
I have made most of the program using a dictionary, but am not sure how to go about with entering the proper command to enter the key for the definition displayed. If anyone could provide suggestions, I'd appreciate it! Also I got some sort of error message when entering this code in and had to do a bunch of indentations, not sure what I did wrong there.
import random

terms = {"1" : "def 1", #Dictionary of 'terms' and 'definitions'
         "2" : "def 2",
         "3" : "def 3"}

menu = None
while menu != "4":
    print("""

    DIGITAL FLASHCARDS!

    1 - List Terms
    2 - Add Term
    3 - Guess Random Definition
    4 - Exit

    """)
    menu = input("\t\t\tEnter Menu option: ")
    if menu == "1":  # List Terms
        print("\n")
        for term in terms:
            print("\t\t\t", term)
        input("\n\tPress 'Enter' to return to Main Menu.\n")

    elif menu == "2":  # Add Term
        term = input("\n\tEnter the new term: ").upper()
        if term not in terms:
            definition = input("\tWhat is the definition? ")
            terms[term] = definition
            print("\n\t" + term, "has been added.")
        else:
            print("\n\tThat term already exists!")
            input("\n\tPress 'Enter' to return to Main Menu.\n")

    elif menu == "3": # Guess Random Definition. Once correct, choose new random definition
        print("\n\t\t\tType 'Exit' to return to Menu\n")
        choice = random.choice(list(terms.values()))
        print("\n\t" + choice + "\n")

        guess = None
        while guess != "EXIT":
            guess = str(input("\tWhat is the term? ")).upper()

A:

display a random definition to try and accurately guess. Once guessed accurately, I would be given the option for another definition to guess

Use terms.items() to get key and value at the same time.
Define the process of generating a new definition question into a function generate_question() to avoid duplicity.
elif menu == "3": # Guess Random Definition. Once correct, choose new random definition
    print("\n\t\t\tType 'Exit' to return to Menu\n")
    def generate_question():
        term, definition = random.choice(list(terms.items()))
        print("\n\t" + definition + "\n")
        return term
    term = generate_question()
    guess = None
    while guess != "EXIT":
        guess = input("\tWhat is the term? ").upper()
        if guess == term:
            print("Correct!")
            if input("\tAnother definition?(y/n)").upper() in ["Y", "YES"]:
                term = generate_question()
            else:
                break

Alternatively, I'd like to just be able to display a random key:value pair, and to continue viewing pairs until I enter EXIT.

elif menu == "4": # Random display a term-definition pair.
    print("\n\t\t\tType 'Exit' to return to Menu\n")
    exit = None
    while exit != "EXIT":
        term, definition = random.choice(list(terms.items()))
        print(term + ":", definition)
        exit = input("").upper()  # Press enter to continue.

Remember to modify the beginning part:
while menu != "5":
    print("""

    DIGITAL FLASHCARDS!

    1 - List Terms
    2 - Add Term
    3 - Guess Random Definition
    4 - View term-definition pairs
    5 - Exit

    """)

