Dev.to AI πŸ€– Ai πŸ‘ 0

Rules in python..

In Python, code structure and logic rely on strict indentation, capitalization, and loop control rules. Breaking any of these rules causes syntax errors or infinite loops. Indentation rules: Any line ending with a col

In Python, code structure and logic rely on strict indentation, capitalization, and loop control rules. Breaking any of these rules causes syntax errors or infinite loops.

Indentation rules:

  • Any line ending with a colon (:), such as while or if, tells Python that a new block of code is starting on the next line.

  • Every line inside that block must be indented by 4 spaces (or one Tab key).

  • If those lines are belongs to that block it should be allinged in vertically

  • If you want to end the block move the line to left side then it will be ended

Capitalization rule:

  • Python treats uppercase and lowercase letters as completely different things.

  • Keywords for truth values must always start with a capital letter, so you must write True and False instead of true or false.

  • Control words like while, if, and, break, and print must always be completely lowercase.

Loop and condition rule:

  • A while loop only runs its code block if the condition next to it evaluates to True. Using while True: forces the loop to run continuously until stopped.
πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.