arrays - Input from the list for python -


assuming have list of names, want print "wrong" if user's input of name not match 1 in list.

my code:

name = ['ali', 'abu', 'amir'] print name  new = raw_input( "enter name") if new == name:     print "correct" else:     print "wrong" 

when input name 'amir' print out "wrong", despite fact in list.

you have replace if new == name: with:

if new in name: 

Comments