0

I am confused on why Python does not see that "u" is in the characters I just put.

I wrote the following:

"u"==("a" or "e" or "i"or "o" or "u")
wjandrea
  • 28,235
  • 9
  • 60
  • 81
Shyam Vyas
  • 61
  • 4
  • 1
    Voting to reopen. The OP doesn't ask how to check it, but asks about the logic behind a very specific case. – Robo Robok Sep 13 '20 at 23:03
  • 1
    Short version: `or` short-circuits, returning the first truthy value. So what you wrote determines that `"a"` is truthy, and the whole parenthetical "returns" `"a"`, rendering the final test `"u" == "a"`. – ShadowRanger Sep 13 '20 at 23:03
  • @RoboRobok: I added another duplicate that asks about the why of this behavior. – ShadowRanger Sep 13 '20 at 23:04
  • @ShadowRanger thanks, that second one suits well enough. – Robo Robok Sep 13 '20 at 23:05
  • @ShadowRanger so how can I get the value of true out of this statement? – Shyam Vyas Sep 13 '20 at 23:16
  • 1
    @Shyam See [Martijn's answer](https://stackoverflow.com/a/15112149/4518341) on "How to test multiple variables against a value?". In short, `"u" in {"a", "e", "i", "o", "u"}`. – wjandrea Sep 13 '20 at 23:24

0 Answers0