0
invalid syntax
when i program in 3.5.2 if 1+1==2: if 2*2==8: print("if") else: print("else") this program shows invalid syntax please help?
3 Antworten
+ 3
1- Don't forget indentation.
2- you must add if statement then else.. But you added 2 if statements, you should have used (elif) ..
3- here is an example that works for your idea :
if ((1+1==2) and (2*2==8)) :
print ("if")
else:
print ("else")
+ 1
I tried the code then after running into the syntax problem a couple hundred times I found out that after pressing enter for print("if") we tend to directly put else: we press enter and that's the problem. Doing this you directly correlate else with print this is wrong. Too overcome this press backspace behind else: then press enter.
0
Vishal Gali you are genius! it works! thank you