- #1
fog37
- 1,568
- 108
- TL;DR Summary
- indentation and nested structures
Hello!
In the context of Python, indentation is very important and mandatory. The entire code is separated into blocks and each block has its own indentation. Two blocks with the same indentation belong are the same block unless the blocks are separated by a block with less indentation, correct?
Nested loops (for or while) and nested if statements (can we talk about nested if-statements?) are considered nested by the interpreter if they have indented relative to the structure they are nested in, correct? Without the indentation, what are they considered? I wrote a block of code that was not meant to be nested but was interpreted as nested because the block was indented.
Thank you!
In the context of Python, indentation is very important and mandatory. The entire code is separated into blocks and each block has its own indentation. Two blocks with the same indentation belong are the same block unless the blocks are separated by a block with less indentation, correct?
Nested loops (for or while) and nested if statements (can we talk about nested if-statements?) are considered nested by the interpreter if they have indented relative to the structure they are nested in, correct? Without the indentation, what are they considered? I wrote a block of code that was not meant to be nested but was interpreted as nested because the block was indented.
Thank you!