python - Matching an input from a string of characters? -
suppose have string -> (a,b,c,1,2,3)
the user pick character string, perhaps b?
pickcharacter=raw_input("pick character? ")
user inputs, 'b'
the code recognizes 'b' character within string , accepts input.
whereas if user inputs 'f', program reject input because character not within string.
how can determine if user picks 1 of following characters list?
string_list = strng.split(",") if pick in string_list: print "yep" else: print "nope"
Comments
Post a Comment