Python 3: how to compare multiple strings in one line of code? -


i'm trying make category select (by text interface) in python 3, , wondering how can compare if multiple strings not true, , print along lines of "that not valid choice"

    input("what category choice?")     if categorychoice != "category1", "category 2", "category 3":     print("not valid choice") 

i don't understand syntax having check if of category1, category2, category3, etc true/false

use in containment tests.

categorychoice = input("what category choice?") if categorychoice not in ("category1", "category 2", "category 3"):     print("not valid choice") 

http://ideone.com/e6n0rr


by way, if you're using python 2, should really use raw_input instead of input.


Comments