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
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'
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
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
"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
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
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
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
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
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
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
> 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
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
13 matches
Mail list logo