官术网_书友最值得收藏!

Indentation

Note the indentation in the for loop block:

    for i in range(10, 1, -1): 
print("Count down no: ", i)

Python executes the block of code under the for loop statement. It is one of the features of the Python programming language. It executes any piece of code under the for loop as long as it has same level of indentation:

    for i in range(0,10): 
#start of block
print("Hello")
#end of block

The indentation has the following two uses:

  • It makes the code readable
  • It helps us identify the block of code to be executed in a loop

It is important to pay attention to indentation in Python as it directly affects how a piece of code is executed.

主站蜘蛛池模板: 五寨县| 德清县| 武邑县| 莱阳市| 泾阳县| 太保市| 商水县| 东至县| 漯河市| 定南县| 东乌珠穆沁旗| 石门县| 南陵县| 乌海市| 沙雅县| 黄陵县| 广宁县| 宿迁市| 鲁甸县| 保定市| 平果县| 寿阳县| 辽阳市| 宁陵县| 垫江县| 武清区| 义马市| 邳州市| 屯昌县| 贵州省| 长宁县| 永嘉县| 巴里| 永昌县| 西安市| 从江县| 安西县| 平乐县| 乳山市| 乐都县| 嘉定区|