What is the expected output of the following snippet?
What is the expected output of the following snippet?
A
Since the else is indented incorrectly, the code will be erroneous!
If the indentation is correct then answer is 3 a=2 if a>0: a+=1 else: a-=1 print(a) If the indentation is not correct, the answer is "the code will be erroneous" a=2 if a>0: a+=1 else: a-=1 print(a)
In the answer given, the indentation error is fixed, therefore the answer would be 3. But because the else is not indented properly in the question, when you run the code it will give an error. Tried this in python itself and a compiler.
error, indentation error
Option D: if ran as in the question, it throws "invalid syntax" error
The code is erroneous.
The code should be erroniouse
3 is the correct answer.
indentation is incorrect: D. the code is erroneous
follow the indentation of the question, the answer is D
Answer is D, There is indentation mistake.
code is not indented properly. Output : line number <number> invalid syntax else: ^^^^
The indentation is not correct
"else" indentation is not correct. so the answer is D. if the indentation is correct, the ans will be 3
Just tested this code and the "else:" has the wrong indentation and therefore, it never worked.
There are 2 mistakes Firstly, there is missed quotes Secondly, the else is not indented correctly
The "else" part is not correctly indented