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

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.

主站蜘蛛池模板: 沾化县| 安阳市| 瑞安市| 鱼台县| 新沂市| 大兴区| 信宜市| 高州市| 堆龙德庆县| 安康市| 宁都县| 常宁市| 应用必备| 卢湾区| 简阳市| 绥德县| 新巴尔虎右旗| 钟祥市| 濉溪县| 上饶县| 惠水县| 石嘴山市| 顺昌县| 武冈市| 禹州市| 思茅市| 革吉县| 郸城县| 孝昌县| 内江市| 茂名市| 开原市| 曲周县| 上饶县| 山阴县| 托克托县| 岑巩县| 平乐县| 桦南县| 广西| 丹寨县|