Python for beginners

Indentation

What we call the indenting method in Python are spaces left at the beginning of a line of code. In other programming languages, indentation was used to make the code easier to read, but in Python it is very important for your code to run.

Look at this;

if 5>2:
   print("5 bigger than 2")

As you can see in the code sample, commands within the scope of a statement are determined by its indentation.


if 10>2:
   print("10 bigger than 2")
     if 10 > 2:
         print("10 bigger than 2")

Here, the program will give us a “syntax” error because the expression is written without using indentation.

Advertisements

*Syntax: In computer science, a syntax error is an error in the syntax of a sequence of characters or tokens that are intended to be written in compile-time. In addition, a program will not compile until all syntax errors are corrected.

Liked it? Take a second to support Selim on Patreon!
Advertisements

Selim

Backend Developer, Öğrenci, Blogger

You may also like...

Yorum yap

%d blogcu bunu beğendi: