- Learn Python in 7 Days
- Mohit Bhaskar N. Das
- 145字
- 2021-07-09 20:40:22
Indentation
The most unique characteristic of Python, unlike other programming languages, is indentation. Indentation not only makes Python code readable, but also distinguishes each block of code from the other. Let's explain this with an example:
def fun():
pass
for each in "Australia":
pass
While writing the code, a new block of code starts with a colon followed by a tab. Here, after the function fun(), a colon is provided which will start the function body, pass is part of the function fun() and it is placed at one tab space. Likewise, the for loop starts with a colon. Here, most people get confused whether to use a tab or space. It is advisable to stick to only one type and follow the same across the whole code. If the indentation is not strictly implemented, then code execution will throw an error.
- 數(shù)據(jù)科學實戰(zhàn)手冊(R+Python)
- 控糖控脂健康餐
- Web Scraping with Python
- 深入淺出Spring Boot 2.x
- Python從入門到精通(精粹版)
- Android NDK Beginner’s Guide
- Backbone.js Blueprints
- Java編程技術(shù)與項目實戰(zhàn)(第2版)
- PHP 7從零基礎到項目實戰(zhàn)
- 從零開始學算法:基于Python
- Java程序設計
- Analytics for the Internet of Things(IoT)
- C語言從入門到精通(第5版)
- Access 2016數(shù)據(jù)庫應用與開發(fā):實戰(zhàn)從入門到精通(視頻教學版)
- JavaScript重難點實例精講