在循环外调用变量

时间:2018-01-25 21:11:01

标签: python python-3.x

我不完全确定为什么这不符合我的意图。所以我在这个编码的小路径游戏中有一个变量;和q2是我想要的:

value = 420
while value > 1:
    q2 = float(input(":"))
    if q2 == 0:
        print("You cannot divide by 0!")
        continue
    value /= q2
    print(value)
    if int(value) == 8:
        print("Correct Answer")
        break

然后在程序中,我试图称之为提供的答案;在这里使用:

print("You must Enter the correct code from the previous answer in the test for a call from your AGENT boss. . .")

while True:
    call = input("*Voice says 'PLEASE ENTER STAR PLUS THE TWO DIGIT CODE FOR ASSISTANCE'*")
    if call == int(q2):
        print("**THE PHONE BEGINS THE RING**")
        break
    elif call != q2:
         print("This will now self destruct")

希望我能够理解我想要实现的目标;当我在IDLE中运行它时,即使在我输入'q2'的值后,它再次给我同一行call = input("*Voice says 'PLEASE ENTER STAR PLUS THE TWO DIGIT CODE FOR ASSISTANCE'*")

0 个答案:

没有答案
相关问题