import random
def question1():
print("What is the Capital of Bangladesh?")
print("Your options are: 1)Dhaka 2)Cumilla 3)Rangpur 4)Barishal")
# p is answer
p = 1
def question2():
print("Where is Bangladesh?")
print("Your options are: 1)in Africa 2)in Asia 3)in Europe 4)in Antertica")
# p is answer
p = 2
n= 1
e= 5000
x= ["a","b"]
while (n==1):
w= random.randint(0,1)
y= x[w]
if "a" in y:
question1()
l= int(input("Type your option number:"))
x.remove(y)
if (p == l):
e=e*2
print("Congrats!You have won" + e)
else:
print("You heve lost!")
print("You answered" + "answers!")
n=n+1
elif "b" in y:
question2()
l= int(input("Type your option number:"))
x.remove(y)
if (p == 2):
e=e*2
print("Congrats!You have won" + e)
else:
print("You heve lost!")
print("You answered" + "answers!")
n=n+1
print("Your total point is:" + e)
我将"p"变量定义为调用函数的McQ问题的答案.但在循环内部,当我调用函数时,"p"变量仍然未定义.我在if语句中的循环中运行了该函数,但它似乎仍未定义.为什么会发生这种事?以及如何修复它?