+ 1

Can i store more than one character in if case

s = input("enter a name") print(s) if(s == suraj) print("you enter right name") but this is wrong program actualy what i want you know by this program so tell me how can i store more than one char in if case

24th Jan 2017, 9:20 AM
Suraj pandey
Suraj pandey - avatar
2 Respuestas
+ 5
You need to enclose the name into quotes, else Python see a variable identifier, and add a second equal sign to do a comparison instead of actually an affectation in your 'if' statement... Oh, and you forgot the colon ( double dot ) at end of line: if ( s == "surah"): You need also to indent the last line, which is inside the 'if' statement ( and not the 'if' line -- with copy-paste I found some indent ^^ ): s = input("enter a name") print(s) if(s == "suraj"): print("you enter right name")
24th Jan 2017, 9:26 AM
visph
visph - avatar
+ 3
if you want another if too you can use 'and'. if (name=='suraj' and fam_name=='tabet'): print('right name and family name')
25th Jan 2017, 6:39 PM
ramzi
ramzi - avatar