我试图让积分系统运行,但是每当我运行它时都说:
UnboundLocalError : Local variable 'teambc' refrenced before assignment:
这是我的代码:-
teambc = 0
teamac = 0
def bst_q(question, answer):
rq = input(str(question))
if rq == answer:
print ('Correct, Well done')
teambc += 1
elif rq != answer:
print ('wrong. Team A now')
rq = input(str(question))
if rq == answer:
print ('Correct, Well done')
teamac += 1
elif rq != answer:
print ('wrong. Both Wrong!')
bst_q('What is 13 times 2?','26')
这取决于您需要使用这两个变量。这是两个工作代码段,请选择所需的代码段:
def bst_q(question, answer):
teambc = 0
teamac = 0
rq = input(str(question))
if rq == answer:
print ('Correct, Well done')
teambc += 1
elif rq != answer:
print ('wrong. Team A now')
rq = input(str(question))
if rq == answer:
print ('Correct, Well done')
teamac += 1
elif rq != answer:
print ('wrong. Both Wrong!')
bst_q("What's your name?","Luigi")