Python's "in" set operator
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3
--
Chapters
00:00 Python'S &Quot;In&Quot; Set Operator
00:18 Accepted Answer Score 128
00:32 Answer 2 Score 112
00:44 Answer 3 Score 3
01:03 Answer 4 Score 15
01:24 Thank you
--
Full question
https://stackoverflow.com/questions/8705...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 3
--
Chapters
00:00 Python'S &Quot;In&Quot; Set Operator
00:18 Accepted Answer Score 128
00:32 Answer 2 Score 112
00:44 Answer 3 Score 3
01:03 Answer 4 Score 15
01:24 Thank you
--
Full question
https://stackoverflow.com/questions/8705...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
ACCEPTED ANSWER
Score 128
Yes, but it also means hash(b) == hash(x), so equality of the items isn't enough to make them the same.
ANSWER 2
Score 112
That's right. You could try it in the interpreter like this:
>>> a_set = set(['a', 'b', 'c'])
>>> 'a' in a_set
True
>>>'d' in a_set
False
ANSWER 3
Score 15
Yes it can mean so, or it can be a simple iterator. For example: Example as iterator:
a=set(['1','2','3'])
for x in a:
 print ('This set contains the value ' + x)
Similarly as a check:
a=set('ILovePython')
if 'I' in a:
 print ('There is an "I" in here')
edited: edited to include sets rather than lists and strings
ANSWER 4
Score 3
Strings, though they are not set types, have a valuable in property during validation in scripts:
yn = input("Are you sure you want to do this? ")
if yn in "yes":
    #accepts 'y' OR 'e' OR 's' OR 'ye' OR 'es' OR 'yes'
    return True
return False
I hope this helps you better understand the use of in with this example.