Loops 同时循环用户输入
我试图问用户2个问题。他们应该回答大于0的数字,但是如果他们回答像1,0或者0,1这样的数字,那仍然是一个有效的答案。如果他们用0回答了这两个问题,那么程序将终止。我在这里哪里出了问题,因为我已经被困在这个问题上一个多小时了Loops 同时循环用户输入,loops,python-3.4,Loops,Python 3.4,我试图问用户2个问题。他们应该回答大于0的数字,但是如果他们回答像1,0或者0,1这样的数字,那仍然是一个有效的答案。如果他们用0回答了这两个问题,那么程序将终止。我在这里哪里出了问题,因为我已经被困在这个问题上一个多小时了 a = 1 b = 1 while a > 0 and b > 0: a = float(input("Enter A: ")) b = float(input("Enter B: ")) if a > 0 and b >
a = 1
b = 1
while a > 0 and b > 0:
a = float(input("Enter A: "))
b = float(input("Enter B: "))
if a > 0 and b > 0:
#calculate equations here
#calculate equations here
#print responses here
#print responses here
elif a == 0 and b == 0:
print("Good bye!")
如果我理解正确,我想你要找的是
a = 1
b = 1
while a > 0 or b > 0:
a = float(input("Enter A: "))
b = float(input("Enter B: "))
if a == 0 and b == 0:
print("Good bye!")
else:
#calculate equations here
#calculate equations here
#print responses here
#print responses here
如果a和b都不等于0,则应该循环