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

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.

主站蜘蛛池模板: 孝感市| 师宗县| 利川市| 峡江县| 平江县| 莱阳市| 威远县| 郁南县| 莆田市| 福建省| 灯塔市| 保定市| 道孚县| 安阳县| 怀安县| 永胜县| 南昌县| 霍州市| 星子县| 关岭| 旬邑县| 太仓市| 青海省| 桃园市| 灵武市| 天津市| 清远市| 柳林县| 泗阳县| 陆川县| 千阳县| 孟连| 林西县| 泗洪县| 乐至县| 潮安县| 天全县| 绥阳县| 江孜县| 武宣县| 开阳县|