x = 15 y = 5 z = 11 print x,y,z #Is this right? if x < y: if x < z: print 'x is least' else: print 'z is least' else: print 'y is least'
The problem with this code is that it doesn't consider different situations. This example compares x and y, and x and z, but it does not compare y and z.
So for example, if we say x = 15, y = 13, z = 11. The code will look and say, okay, x is not less than y. It'll skip down to the else statement, and print 'y is least'. In actuality, z is least, but the program never compares y and z.
no subject
x = 15
y = 5
z = 11
print x,y,z
#Is this right?
if x < y:
if x < z: print 'x is least'
else: print 'z is least'
else: print 'y is least'
The problem with this code is that it doesn't consider different situations. This example compares x and y, and x and z, but it does not compare y and z.
So for example, if we say x = 15, y = 13, z = 11.
The code will look and say, okay, x is not less than y. It'll skip down to the else statement, and print 'y is least'.
In actuality, z is least, but the program never compares y and z.
(Reposted to fix a small mistake.)