Please explain the difference between the two programs | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Please explain the difference between the two programs

A) x=6 y=7 if x>y: print ("x is greater than y") else: print ("y is greater than x") B) x=6 y=7 if x>y: print ("x is greater than y") else: print ("y is greater than x") output of A is : syntax error in "else" output of B is : y is greater than x please explain why I get a syntax error in A

15th Dec 2016, 6:00 AM
Debanjona Nath
Debanjona Nath - avatar
3 Answers
+ 4
because identation. It's a syntax error because you get the else, but you don't have an if in that code block.
15th Dec 2016, 6:02 AM
Nahuel
Nahuel - avatar
0
ooh thank!
15th Dec 2016, 6:10 AM
Debanjona Nath
Debanjona Nath - avatar
0
space before else should be removed
21st Dec 2016, 8:26 PM
Chinmai A Khanderaya
Chinmai A Khanderaya - avatar