0

In Python, is it possible to test a variable against multiple values, i.e. a shorter way of writing:

if (x=="a") or (x=="b") or (x=="c") ... 

like maybe: if x=="a" or "b" or "c":?

Tchaikovsky
  • 333
  • 2
  • 4
  • 11
  • You don't need the (). – Cate Daniel Sep 27 '14 at 02:07
  • Probably [How do I test one variable against multiple values?](http://stackoverflow.com/q/15112125/1399279) is a better duplicate... – SethMMorton Sep 27 '14 at 05:52
  • I have seen that question, and it is slightly different. It is asking if one of a set of variables is equal to a given value, not whether a single variable is equal one of a set of values, which is my query. – Tchaikovsky Sep 27 '14 at 18:53

0 Answers0