>>> range(5)
[0, 1, 2, 3, 4]
>>> range(5, 10)
[5, 6, 7, 8, 9]
To test for a number in a range you can use 10 < n < 90: >>> x = 1 >>> 10 < x < 90 False >>> x = 15 >>> 10 < x < 90 True >>> x = 100 >>> 10 < x < 90 False
Kent
Marc Gartler wrote:
Hi all,
I am fairly new to both Python & programming, and am attempting to create a function that will test whether some user input is an integer between 10 and 89, but the check isn't happening...
def check_range(myrange): if range(myrange) != range(10,89): return "False" else: return "True"
...this gets called later via: if check_range(input): done = "True" return int(input)
What am I doing wrong?
Thanks!
_______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor