I’m writing an if statement in Python with a lot of OR conditions. Is there an elegant way to do this with a list, within in the condition rather than looping through the list?
In other words, what would be prettier than the following:
if foo == 'a' or foo == 'b' or foo == 'c' or foo == 'd':
I’ve just taken up Python, and the language has me wanting to write better.
I will also note that your answer is wrong for several reasons: