if的多个条件

时间:2015-10-24 10:35:08

标签: python python-2.7 if-statement

我正在尝试使用if...and语句检查是否满足了两个条件:

if foo < 0 and bar < 0:
    #do something

但它总是回归正面。为什么呢?

以下是完整的代码:

loop = 1
while loop == 1:
    t = raw_input("Please enter a number.")
    d = raw_input("Please enter another number")
    limit = raw_input("Please enter another number")
    try:
        t = int(t)
        d = int(d)
        limit = int(limit)
        loop = 0
    except ValueError:
        print "Sorry, but one of those was an invalid input. Please ensure you enter only numbers greater than zero."
    if t > 0 and d > 0:
        loop = 0
    else:
        pass

1 个答案:

答案 0 :(得分:0)

foobar的价值到底是什么?
工作示例:

a = 'True' 
b = 'True'

if (a and b):
    print('Both True')

c = 'Hello'
d = 'Hello'

if (c == d):
    print('Equal')