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

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.

主站蜘蛛池模板: 西城区| 逊克县| 睢宁县| 安化县| 襄城县| 六枝特区| 江陵县| 兴国县| 东台市| 武安市| 兰西县| 新兴县| 商丘市| 白水县| 九江县| 伊金霍洛旗| 满城县| 亳州市| 绿春县| 万载县| 贵州省| 凉山| 崇仁县| 广丰县| 怀宁县| 临澧县| 涟源市| 大理市| 柘荣县| 旺苍县| 玉田县| 沙田区| 珲春市| 阜南县| 金坛市| 大同县| 翼城县| 木兰县| 滕州市| 大冶市| 密山市|