I dont get this!

Peter Sundling peter.sundling at telia.com
Thu Aug 23 18:16:49 EDT 2001


Help! :)
I have been programming in python for some time now, and today i
found a strange bug in my code i cant get rid of...

Here is a code snippet where something is wrong somewhere:


def check_hilo(i):
	if value[i] < low[i]:
		return 1

	if value[i] > high[i]:
		return 2

	return 0


...Simple, huh? I have never had any trouble with something like this
before.
The thing is that this procedure always returns 1.
I have tried to rewrite this little source code a couple of times,
in many different ways, and it still returns 1!

If i compare value to high before i compare it to low, it still returns
1.

As an example: value[i] was 103, low[i] was 25 and high[i] was 35.
As far as i know, 103 is greater than 25. But python seemes to disagree
on that...
( if i start the python alone and writes
print 103 < 25
it responds 0, But what the hell is wrong now??)


/Peter
(The dumbest programmer on the face of the earth)



More information about the Python-list mailing list