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

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.

主站蜘蛛池模板: 天峻县| 武汉市| 天峨县| 顺平县| 平邑县| 当阳市| 民权县| 鄢陵县| 丹江口市| 陆丰市| 江都市| 江都市| 长子县| 萨嘎县| 紫金县| 湘潭市| 辽阳市| 呼伦贝尔市| 铅山县| 绍兴市| 兴仁县| 顺昌县| 隆林| 深圳市| 鄂托克前旗| 临江市| 康定县| 桂东县| 玉门市| 肇东市| 钟山县| 凉山| 本溪市| 汝州市| 西盟| 师宗县| 瑞安市| 自贡市| 清镇市| 库尔勒市| 旌德县|