Re: [Tutor] check_range

2004-12-15 Thread Juan Shen
I agree with Kent's opinion. A boolean statement, like 9>> ( 9 < value ) and ( value < 90 ) , maybe a good sense of boolean type will be made, because 'and' operation is always associating with boolean. Juan Shen 在 2004-12-15三的 07:43 -0500,Kent Johnson写道: > Brian van den Broek

Re: [Tutor] check_range

2004-12-15 Thread Liam Clarke
I'll second this - > In general, Python's flexibility with boolean values is a strength of the > language and I recommend > you try to get comfortable with it. If you come across something, and you're not sure if it'll evaluate true or false, fire up IDLE or similar intepreter, and test it! I'

Re: [Tutor] check_range

2004-12-15 Thread Kent Johnson
Brian van den Broek wrote: DogWalker said unto the world upon 2004-12-15 00:32: "Brian van den Broek" <[EMAIL PROTECTED]> said: I have a some style suggestions for you, too. Try it this way: def check_in_range(value): in_range = False if 9 < value < 90: in_range = True

Re: [Tutor] check_range

2004-12-15 Thread Brian van den Broek
DogWalker said unto the world upon 2004-12-15 00:32: "Brian van den Broek" <[EMAIL PROTECTED]> said: Marc Gartler said unto the world upon 2004-12-14 18:12: 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 int

Re: [Tutor] check_range

2004-12-14 Thread DogWalker
"Brian van den Broek" <[EMAIL PROTECTED]> said: >Marc Gartler said unto the world upon 2004-12-14 18:12: >> 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 ch

Re: [Tutor] check_range

2004-12-14 Thread Marc Gartler
Thanks all, that was very helpful! On Tuesday, December 14, 2004, at 06:39 PM, Brian van den Broek wrote: Marc Gartler said unto the world upon 2004-12-14 18:12: 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

Re: [Tutor] check_range

2004-12-14 Thread Brian van den Broek
Marc Gartler said unto the world upon 2004-12-14 18:12: 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(myr

Re: [Tutor] check_range

2004-12-14 Thread Jeff Shannon
Jeff Shannon wrote: if myrange in range(10,90): # "in" is the key word here return True else return False This is, however, the correct solution. :) Or I *should* say, rather, that this is *a* correct solution, in that it will yield the expected answer. Kent Johnson's '10 < x < 90' is

Re: [Tutor] check_range

2004-12-14 Thread Liam Clarke
Oh, and you can return True and False without quotation marks. >f check_range(input): >done = "True" > return int(input) You wil also hit problems with this, unless you're using input() to get the integer, which causes even more issues. Apparently, input() evaluates t

Re: [Tutor] check_range

2004-12-14 Thread Jeff Shannon
R. Alan Monroe wrote: def check_range(myrange): if range(myrange) != range(10,89): return "False" else: return "True" For this to work out, the user's input would have to be a giant string containing 10, 11, 12, 13, etc. Not quite, actually. Presuming th

Re: [Tutor] check_range

2004-12-14 Thread Kent Johnson
You misunderstand what range() does. It returns a list of numbers starting with the lower one and up to but not including the upper one: >>> 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 = 1

Re: [Tutor] check_range

2004-12-14 Thread R. Alan Monroe
> def check_range(myrange): > if range(myrange) != range(10,89): > return "False" > else: > return "True" For this to work out, the user's input would have to be a giant string containing 10, 11, 12, 13, etc. Unless I mistunderstood your requirement

[Tutor] check_range

2004-12-14 Thread Marc Gartler
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