0

Indention

What happens if you indent code without having a statement that needs invention before (like if, for, def...) ? Will it run?

16th May 2017, 8:37 PM
Carl
3 Answers
+ 7
No. Indentation is very rigid in Python and is part of the syntax. It's like forgetting a semi-colon in C++ or Java :)
16th May 2017, 9:01 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 7
Python enforces indentations to keep blocks of codes together. This is similar to C/C++, Java and other languages using {} to keep stuff together.
17th May 2017, 2:34 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
you will get an error "unexpected indent"
16th May 2017, 8:41 PM
ifl
ifl - avatar