+ 1

Indentation

I think the indentation of «raise» in the example try except it's wrong. Somebody can confirm that?

21st Apr 2017, 10:16 PM
Luis Garcia
Luis Garcia - avatar
5 Answers
+ 2
Hello, It is not wrong. The lesson wants to show you how to raise an error of your choice inside the "except" section... That's why the indentation...
22nd Apr 2017, 11:25 AM
matan
+ 1
There must be indentation. In python the indentation is similar to the {} in other codes... It means that the command is inside thr function. Hence, since you want to raise the error only if we are INSIDE the exception, the raise should be indented. Hope I helped ^_^
22nd Apr 2017, 9:12 PM
matan
0
Thank you for responding. What I meant is that in the example explanation there is no indentation but when you run it there is an indentation. Which is the correct one?
22nd Apr 2017, 7:46 PM
Luis Garcia
Luis Garcia - avatar
0
yes there is indentation, the raise should be put down under print() in above example. and if you worrying about the output error, so don't.. it is expected by the code to raise the exception.
27th Apr 2017, 10:22 PM
Abraiz Khan
Abraiz Khan - avatar
0
Can someone explain about if statements and indentation with an example.?
19th Aug 2021, 1:02 PM
Kommishetty Sri Vijaya Jahanavi