- 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.
推薦閱讀
- Mastering Proxmox(Third Edition)
- 腦動(dòng)力:C語(yǔ)言函數(shù)速查效率手冊(cè)
- HBase Design Patterns
- OpenStack Cloud Computing Cookbook(Second Edition)
- Implementing Oracle API Platform Cloud Service
- 數(shù)據(jù)庫(kù)系統(tǒng)原理及應(yīng)用教程(第5版)
- 人工智能趣味入門(mén):光環(huán)板程序設(shè)計(jì)
- 水下無(wú)線傳感器網(wǎng)絡(luò)的通信與決策技術(shù)
- 運(yùn)動(dòng)控制系統(tǒng)
- Extending Ansible
- 多媒體制作與應(yīng)用
- 貫通Java Web輕量級(jí)應(yīng)用開(kāi)發(fā)
- 菜鳥(niǎo)起飛電腦組裝·維護(hù)與故障排查
- 分布式Java應(yīng)用
- 51單片機(jī)應(yīng)用程序開(kāi)發(fā)與實(shí)踐