- 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.
推薦閱讀
- 基于LabWindows/CVI的虛擬儀器設計與應用
- Mastering VMware vSphere 6.5
- WOW!Illustrator CS6完全自學寶典
- 永磁同步電動機變頻調速系統及其控制(第2版)
- Learning C for Arduino
- 液壓機智能故障診斷方法集成技術
- Unity Multiplayer Games
- Linux Shell編程從初學到精通
- 大數據案例精析
- MPC5554/5553微處理器揭秘
- Mastering Predictive Analytics with scikit:learn and TensorFlow
- 中文版Photoshop情境實訓教程
- DynamoDB Applied Design Patterns
- Getting Started with Tableau 2019.2
- CPLD/FPGA技術應用