0

Syntax Error

copy of my python program bt. else statement is no output. x=4 if x==5: print ("Yes") else: print ("No") output: syntax error

27th Sep 2016, 1:45 PM
Thameshwar Sinha
Thameshwar Sinha - avatar
4 Respuestas
+ 3
x=4 if x==5: print ("Yes") else: print ("No") don't forget about spaces!
27th Sep 2016, 2:14 PM
Raphael
Raphael - avatar
0
kkh
29th Sep 2016, 11:25 AM
Thameshwar Sinha
Thameshwar Sinha - avatar
0
x=4 if x==5: print ("Yes") else: print ("No") output: syntax error It is because you've indented the else statement wrongly. It should have the same indentation with the if statement. Like This; x=4 if x==5: print ("Yes") else: print ("No") output: No
1st Oct 2016, 8:05 AM
Umar Muhummed
Umar Muhummed - avatar
0
it is due to indentation when you write if related else at same level
10th Oct 2016, 4:58 PM
Prakash
Prakash - avatar