Sytnax error while adding "Exception" in python


This error has arised because of the wrong indentation done in your python script.
so try changing the code as follows : ( FOLLOW THE INDENTATION )

If any issues still occurs please let me know!

Happy learning :man_student:t2:

1 Like

thanks a lot for your effort and explanation brother! didn’t know about the indentation

cool ! Don’t worry if there is anything just ask it don’t hesitate.

If you think the above solution has helped you please do give it a thumbs up!


Hello @iamadhi47,
Don’t worry Indentation is nothing but the correct spacing.
Programming languages like C we can specify the block of codes(loops,if statements etc,) using the curly braces{ } but in python it is specified using the spaces from the line starting(indentation).
So,solving the issue is done by retyping the code without any extra or insufficient spaces.
Try this and let me know once the issue is solved

In python,Indentation problem is face more about every programmer.

<4 spaces(not TAB)>{code}
<4 spaces(not TAB)>{code}
<4 spaces(not TAB)>if(condition)
<4 spaces(not TAB)><4 spaces(not TAB)>{code}

Please remember in python program we use space bar (4 spaces) not TAB(8 spaces).

In Python Programming language indentation is very important. The try block should always be followed by an except block, in order to handle errors. Hence both should have the same indentation