⊗pyPmCdIn 127 of 208 menu

Indentation in if-else construct in Python

In Python, indentation determines which blocks of a if-else construct are paired. Therefore, the lines below each block must be one indent apart. This is equal to four spaces or one tab.

Let's look at the general scheme of the if-else condition. In the correct version, the code should be one indent away from its block with the condition:

if comparison operation: code else: code

If you remove the indentation, Python will return an error:

if comparison operation: code else: code
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline