I think what you probably want is "if 1 <= i < 9" or something similar. You could equivalently write "if i in range(1,9)" but the other way is preferred because using in like this actually loops over every number between 1 and 9 and checks whether that number is equal to i.
Hope this helps, Mike Jonah Fishel wrote:
If I had this:
def print_i(i):
if i == range(1, 9):
print "It worked!"
else:
print "Bummer!"
print_i(6)
Why would I get Bummer! every time? Am I misusing range()?
Thanks,
globalp