The Python Oracle

Why does "a == x or y or z" always evaluate to True? How can I compare "a" to all of those?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: The Builders

--

Chapters
00:00 Question
01:30 Accepted answer (Score 213)
04:09 Answer 2 (Score 7)
06:09 Answer 3 (Score 6)
07:15 Answer 4 (Score 3)
08:00 Thank you

--

Full question
https://stackoverflow.com/questions/2000...

Question links:
[How to test multiple variables for equality against a single value?]: https://stackoverflow.com/questions/1511...

Accepted answer links:
[chooses the first operand]: https://stackoverflow.com/questions/4700...
["truthy"]: https://stackoverflow.com/questions/3998...
[would satisfy an ]: http://docs.python.org/3/library/stdtype...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #boolean #booleanexpression

#avk47