Indentation Concept – CSKC
Sign In

Search

Code Learning #PYTHON#8216    siteicon   siteicon  

Indentation Concept

We need to indent instructions that fall under if, for, while def etc. Simple instructions in the main body can not be indented, while instructions within some condition, loop, function etc. must be indented. This is done by giving equal space or tabs on the left side of each instruction within a block.

Source Code

TC++ #8216

Source Code

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test Python

Notes

  • One must follow PEP-8 style guide for indentation rules
  • In python indents can be any number of spaces or tabs, the only requirement is they need to be equal for instructions at equal level. Although as per style guide 4 spaces as indents should be used.
  • Spaces and tabs should not be mixed while indentation.
  • Instruction in the main body can not be indented.
  • If we are making nested conditions or loops (means if within if or while within while etc.) then indents also need to be nested in the similar fashion.


Suggested Filename(s): indent.py, indentation.py, indentation_concepts.py



Share

Created: 11-Apr-2026 20:29 | Updated: 17-Sep-2026 11:25|