Simple Quiz - How Do I Link Variables?
<p>I'm stuck trying to figure out how to match the correct answer with the correct question. Right now if the user's answer is equal to any of the answers, it returns correct. Please help.</p>

<pre><code>easy_question = "The capitol of West Virginia is __1__"
medium_question = "The device amplifies a signal is an __2__"
hard_question = "A program takes in __3__ and produces output."

easy_answer = "Charleston"
medium_answer = "amplifier"
hard_answer = "input"

questions_and_answers = {easy_question: easy_answer, 
                    medium_question: medium_answer,
                    hard_question: hard_answer}
#print(easy_answer in [easy_question, easy_answer])
#print(questions_and_answers[0][1])

print('This is a quiz')
ready = input("Are you ready? Type Yes.")
while ready != "Yes":
    ready = input("Type Yes.")
user_input = input("Choose a difficulty: Easy, Medium, or Hard")

def choose_difficulty(user_input):
    if user_input == "Easy":
        return easy_question
    elif user_input == "Medium":
        return medium_question
    elif user_input == "Hard":
        return hard_question
    else:
        print("Incorrect")
        user_input = input("Type Easy, Medium, or Hard")
print(choose_difficulty(user_input))


answer = input("What is your answer?")
def check_answer(answer):
    if answer == easy_answer:
        return "Correct"
    elif answer == medium_answer:
        return "Correct"
    elif answer == hard_answer:
        return "Correct"
 print(check_answer(answer))
</code></pre>

<p>You will want to keep track of the <code>question</code>:</p>

<pre><code>question = choose_difficulty(user_input)
print(question)

answer = input("What is your answer?")
def check_answer(question, answer):
    if questions_and_answers[question] == answer:
        return "Correct"
    return "Incorrect"
print(check_answer(question, answer))
</code></pre>

<p>There's a lot more cool stuff you can do, but this is a minimal example that should solve your problem!</p>

<p><strong>EDIT:</strong></p>

<p>When you did</p>

<pre><code>questions_and_answers = {easy_question: easy_answer, 
                medium_question: medium_answer,
                hard_question: hard_answer}
</code></pre>

<p>you created a dictionary (or <code>dict</code> as it's known in Python). See <a href="https://docs.python.org/2/tutorial/datastructures.html#dictionaries" rel="nofollow">examples</a>. Basically, you can do lookups by the first term (the question) and it'll return the second term (the answer).</p>

python