Write a program to repeatedly prompt the user to enter the capital of a state. Upon receiving the user’s input, the program reports whether the answer is correct. Assume the states and their capitals are stored in dictionaries as key-value pairs

 

Question = {
    'Gujarat':'gandhinagar',
    'Maharastra':'mumbai',
    'Rajasthan':'jaipur',
    'Delhi':'new delhi'
}

for que, ans in Question.items():
    answer = input(f"what is the capital of {que} :")
    if answer == ans:
        print("You are right")
    else:
        print("You are wrong" )





output:
what is the capital of Gujarat :gandhinagar
You are right
what is the capital of Maharastra :mumbai
You are right
what is the capital of Rajasthan :jaipur
You are right
what is the capital of Delhi :new delhi
You are right

Comments

Post a Comment