Python 3.2 how to set correct and incorrect answer on questions inside 2 lists
<p>I am making 2 sets of question, first set (list1) is all yes and second (list2) is all no 10 questions each then I used random.choice to randomly pick a question from the 2 sets. I want to make an output of "correct" whenever random.choice picks a question from list 1 when the user answered "Y" same with list2 if the user answered "N". Here is my code:</p>

<pre><code>import random


Count = 0

list1 = ['1+1=2?','2+2=4?','3+3=6?','4+4=8?','5+5=10?','15+15=30?','16+16=32?','17+17=34?','18+18=36?','19+19=38?']
list2 = list2 = ['20+20=10?','6+6=2?','7+7=11?','8+8=32?','9+9=21?','10+10=0?','11+11=4?','12+12=12?','13+13=25?','14+14=13?']
list = list1 + list2

while(Count &lt; 5):
    print(random.choice(list))
    Answer = input("Answer: ").upper()
    Count = Count+1
    if(list == list1):
       if(Answer == "Y"):
          print("Correct")
       else:
          print("Incorrect")
    if(list == list2):
       if(Answer == "N"):
          print("Correct")
       else:
          print("Incorrect")
</code></pre>

<p>I cannot figure out how to output the correct and incorrect statement. Any help would be truly appreciated.</p>

<p>First off, don't use python keywords and built-in type names as your variable names.</p>

<p>You can check the membership of random choice simply with <code>in</code> operator.</p>

<pre><code>import random

list1 = ['1+1=2?','2+2=4?','3+3=6?','4+4=8?','5+5=10?','15+15=30?','16+16=32?','17+17=34?','18+18=36?','19+19=38?']
list2 = ['20+20=10?','6+6=2?','7+7=11?','8+8=32?','9+9=21?','10+10=0?','11+11=4?','12+12=12?','13+13=25?','14+14=13?']
lst = list1 + list2

for _ in range(5):
    value = random.choice(lst)
    print(value)
    Answer = input("Answer: ").upper()
    if(Answer == "Y"):
        if value in list1:
            print("Correct")
        else:
            print("Incorrect")
    elif(Answer == "N"):
        if value in list2:
            print("Correct")
        else:
            print("Incorrect")
    else:
        print("Enter Y or N")
</code></pre>

python python-3.x