Mega Code Archive

 
Categories / Python Tutorial / Statement
 

Use if statement to compare string

x = 'A' if x == 'c':     print "c" elif x == 'b':     print "b" else:     print 'A!'