Your test does not work because the number is a string.
>>> '-1' <= 0
False
You need to convert numberto an integer:
number = int(sys.argv[1])
Note that in Python 3.0, your code would give an error, making it easier to find your error:
>>> '-1' <= 0
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
'-1' <= 0
TypeError: unorderable types: str() <= int()
source
share