- Python Programming with Raspberry Pi
- Sai Yamanoor Srihari Yamanoor
- 119字
- 2021-07-02 23:48:45
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.
推薦閱讀
- 手把手教你學AutoCAD 2010
- Mobile DevOps
- Cloud Analytics with Microsoft Azure
- 2018西門子工業專家會議論文集(上)
- Apache Hive Essentials
- STM32嵌入式微控制器快速上手
- INSTANT Autodesk Revit 2013 Customization with .NET How-to
- 網絡綜合布線設計與施工技術
- 變頻器、軟啟動器及PLC實用技術260問
- Statistics for Data Science
- 一步步寫嵌入式操作系統
- ZigBee無線通信技術應用開發
- Mastering MongoDB 4.x
- JSP通用范例開發金典
- Mastering SQL Server 2014 Data Mining