通过while循环运行时获得正确的输出

时间:2017-09-07 11:35:39

标签: python loops input while-loop

 a = 1
 b = ""
 while a != b :
   a = float(input("enter value a: "))
   b = float(input("enter value b: "))
   if a == b:
     print("Thats correct") 
   elif a > b:
     print("a is higher")
   elif b > a:
     print("b is higher")
   else:
     print("not correct input, please try again"

如何更改代码,以便在测试a或b的输入值为字符串时,循环会继续?如果输入值相同但都是字符串,则循环也需要继续。

0 个答案:

没有答案
相关问题