I'm trying to check that two conditions are fulfilled with an if...and
statement:
if foo < 0 and bar < 0:
#do something
but it's always returning positive. Why?
Here is the complete code:
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
What exactly is the value that you have in foo
and bar
?
Working example:
a = 'True'
b = 'True'
if (a and b):
print('Both True')
c = 'Hello'
d = 'Hello'
if (c == d):
print('Equal')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.