Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 同时循环用户输入_Loops_Python 3.4 - Fatal编程技术网

Loops 同时循环用户输入

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 >

我试图问用户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 > 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,则应该循环