from easygui import *
from time import *
from statedict import *
import random
correctnum = 0
questionsanswered = 0
print("Indian Map Quiz v1")
sleep(0.5)
print("Note all features might not work correctly, this is a work in progress.")
msgbox("Welcome to Indian Map Quiz", "INDIA", "Continue")
title = "Guess The State"
msg = "What Indian state is this?"
stateFactList = [APdict, ARdict, ASdict, BRdict, CTdict, GAdict, GJdict, HPdict, HRdict, JHdict,
KAdict, KLdict, MHdict, MLdict, MNdict, MPdict, MZdict, NLdict, ODdict, PBdict,
RJdict, SKdict, TGdict, TNdict, TRdict, UPdict, UTdict, WBdict]
stateID = random.choice(stateFactList)
print(stateID["state"])
stateQuestion = buttonbox(msg=msg, title=title, choices=stateID["choices"], image=stateID["image file"])
if stateQuestion == stateID["correct"]:
print("it's correct")
correctnum += 1
questionsanswered += 1
else:
print("incorrect")
questionsanswered += 1
Here is the code, essentially when you run the program, it should randomly pick a state and provide some multiple choice answers based on the state. It randomly picks a state from the stateFactlist list and matches it with a dictionary stored in another file. Whenever the user answers a question, I want it to generate a new, random state to be displayed to the user, along with the respective multiple choice answers, but I can't find a way to implement it. Help is appreciated.