I have Python code at the moment which does something like this:
if plug in range(1, 5):
print "The number spider has disappeared down the plughole"
But I actually want to check if the number is not in range. I've googled and had a look at the Python documentation, but I can't find anything. How can I do it?
Additional data: When running this code:
if not plug in range(1, 5):
print "The number spider has disappeared down the plughole"
I get the following error:
Traceback (most recent call last):
File "python", line 33, in <module>
IndexError: list assignment index out of range
I also tried:
if plug not in range(1,5):
print "The number spider has disappeared down the plughole"
Which returned the same error.
not in range(1, 5)
?plug
is of type integer or the check does not worknot
is actually has lower precedence thanin
, soplug not in range(1,5)
will work just fine.