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

  • 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.

主站蜘蛛池模板: 博湖县| 来安县| 德格县| 巨鹿县| 额济纳旗| 崇信县| 中西区| 罗源县| 南投县| 镇康县| 齐齐哈尔市| 遂昌县| 道孚县| 天镇县| 广东省| 伊宁县| 黄骅市| 西平县| 东丽区| 镇平县| 苗栗市| 博野县| 洪雅县| 天镇县| 榆社县| 龙江县| 垦利县| 贵溪市| 修武县| 新野县| 上饶县| 博爱县| 望都县| 武功县| 凯里市| 安仁县| 通城县| 太和县| 花莲县| 峨眉山市| 长宁县|