Need to check if an answer in a quiz is correct (Python)
Question: So I have a dictionary with legislators and the parties they belong to. Five
questions are outputted with random names and parties and the input is either
Y or N. I need to now figure out how to check if its true or not but I am
stumped. The code:

    
    
    from random import *
    
    legislators = { "Tsang Yok-sing" : "DAB", "Albert Ho" :
    "Democratic", "Lee Cheuk-yan" : "Labour", "James To" :
    "Democratic", "Chan Kam-lam" : "DAB", "Lau Wong-fat" :
    "Economic Synergy", "Emily Lau" : "Democratic" }
    
    names = list(legislators.keys())
    parties = list(legislators.values())
    
    numberCorrect = 0
    
    for i in range(0, 5):
        name = names[randrange(len(names))]
        party = parties[randrange(len(parties))]
        ans = input("Does "+name+" belong to "+party+" (Y/N)?\n")
    

Just need to get any advice on where to start on this. Thanks a lot!


Answer: 
    from random import *
    
    legislators = { "Tsang Yok-sing" : "DAB", "Albert Ho" :
    "Democratic", "Lee Cheuk-yan" : "Labour", "James To" :
    "Democratic", "Chan Kam-lam" : "DAB", "Lau Wong-fat" :
    "Economic Synergy", "Emily Lau" : "Democratic" }
    
    names = list(legislators.keys())
    
    parties = list(legislators.values())
    
    numberCorrect = 0
    
    for i in range(0, 5):
    
        name = names[randrange(len(names))]
    
        party = parties[randrange(len(parties))]
    
        ans = raw_input("Does "+name+" belong to "+party+ " Y/N?")
    
        if ans == 'Y':
    
            if legislators[name] == party:
    
                print 'correct'
    
            else:
                print 'error'
    
        elif ans == 'N':
    
            if legislators[name] == party:
    
                print 'error'
            else:
    
                print 'correct'
    

