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

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.

主站蜘蛛池模板: 青冈县| 手机| 民权县| 饶阳县| 鱼台县| 会理县| 青田县| 旌德县| 阿克| 友谊县| 汶川县| 罗江县| 隆尧县| 黄龙县| 保靖县| 宾川县| 博客| 西贡区| 东安县| 新绛县| 微山县| 磴口县| 天峻县| 绥芬河市| 兴城市| 牡丹江市| 平顺县| 琼海市| 介休市| 平果县| 教育| 贵定县| 巨鹿县| 理塘县| 芜湖县| 合作市| 十堰市| 湖口县| 靖宇县| 屯昌县| 彰化市|