0

Regarding Indentation in python:

When it comes to indentation in python, does each line of code in looping / iteration statements need to be spaced up by a tab space every time. Coz, sometimes I get an error saying "Unexpected indentation". So, how does it work?

27th Dec 2021, 12:17 PM
Ishvarya
1 Antwort
+ 2
If you have a for loop, then everything you want to do in the for loop needs to be indented. If you don't want something done N amount of times, "step out of the loop" meaning those next lines you write are not indented under the loop. for n in whatever: do this thing # inside loop do this too # inside loop do this after loop # outside loop
27th Dec 2021, 12:25 PM
Slick
Slick - avatar