On 11/1/07, James Paige <[EMAIL PROTECTED]> wrote: > No, you are not misusing range() you are misusing == > > == is for checking if two things are equal. To check if a value is in a > list, use the "in" operator, like this: > > def print_i(i): > if i in range(1, 9): > print "It worked!" > else: > print "Bummer!" Like has been said here before, use something like:
if i <= 9 and i >= 1: because otherwise it will iterate and be slow. In this case, about ten times as slow. Also, it won't work with decimals. Ian