python - If statement checking if a variable is equal to a specific word is getting invalid syntax -


so, i'm trying make easter egg in calculator program, if type friend johns name in, prints nerd, keep getting invalid syntax on line if statement starts. here's code looks like:

x = input(' ') if x = john:     print nerd else:     print x 

please keep in mind i'm using python 2.7, not 3. when googled it, got answers worked in 3.

x = raw_input('enter name ') if x == 'john':     print 'nerd' else:     print x 

you doing assignment, need == check equality


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -