我正在尝试使用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
答案 0 :(得分:0)
foo
和bar
的价值到底是什么?
工作示例:
a = 'True'
b = 'True'
if (a and b):
print('Both True')
c = 'Hello'
d = 'Hello'
if (c == d):
print('Equal')