So I'm currently going through the python course and am currently at loops part 4. It has the following instructions:
Fill in the loop condition so the user will be prompted for a choice over and over while choice does not equal 'y' and choice does not equal 'n'.
In previous excercises I've stumbled upon some code like this:
if x not in range(0,5) or y not in range(0,5):
print "Do this stuff"
print "Do that stuff
This made me to try to and use the previous syntax applied to this excercise. But seeing the hint eventually corrected me into using !=.
Now my question: when do you use the
is not / not in for conditions and when do you use
!= because it seems to me you could form the condition so it can work with both.
For some reason I tend to think that the != condition is used for strings and single integers, and the other one to check values in a list.
Could someone confirm or elaborate on this topic to shed some clarity over this? I thank you in advance.