如何在问题中看到错误的数学时间

时间:2016-03-29 07:10:28

标签: python

如何打印问题回答错误的次数?

while 1:
    math = input("(1)    What Is 8 x 4 : ")
    if not math.isdigit():
        print("It's not number")
    elif math == "32":
        print("You Got The Question Correct")
        break
    else:
        print("Sorry You Got The Question Wrong Try Again")

1 个答案:

答案 0 :(得分:1)

  1. 创建一个变量来存储值
  2. 每当获得错误答案时更新值
  3. 打印值

    wrongTry = 0 #read 1.
    while 1:
        math = input("(1)    What Is 8 x 4 : ")
        if not math.isdigit():
            print("It's not number")
            wrongTry = wrongTry + 1 #read 2.
        elif math == "32":
            print("You Got The Question Correct")
            break
        else:
            print("Sorry You Got The Question Wrong Try Again")
            wrongTry = wrongTry + 1 #read 2.
        print(wrongTry) #read 3.