pythonif-statement

How to end if statement in python


I have touched on other programming languages ​​for example: PHP, HTML, C #, C ++ etc. But I could not understand Python a bit from the programming languages ​​I listed.

When I try to start an if statement in Python I will have to start with : but I cannot find a way to end it. I mean, if the if statement is activated, some code must be executed, so I can not find a way to see which code will be executed when the if statement is activated.


Solution

  • In python what you have to understand about block of code, is just indentation. check the following example:

    if 10 > 20:
       print('Inside if statement')
    print('Outside if statement')
    

    And the same goes to loop, function, class,... In c#, c++, c we use {} to define a block of code but in python is just indentation