Why does python code indent different output results?
Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply content: hahahahahahahahahahahahahahahahahahahahahahaha
Of course it is different. The first print (each_item) is included in the first for statement, and the second print (each_item) is included in the second for statement. of course it is different. The block indentation of Python is c and c ++ {}.
The three of you indents print to for if, of course, they are different. Python does not have {}, so we have to use indentation to partition it...
Add jokes upstairs
--------------------
I am a beginner in python. I just opened the new teaching material yesterday and saw the first page:
What you need:
-Notepad ++
-Powershell
-Vernier caliper
Slow down! What should I do with a vernier caliper?
I ignored that line and started to learn by myself. Then, I can see that the code in the previous chapter is relatively long and pages are turned over. Didn't you see Chapter 1? Python uses indentation to control the statement structure. the first output statement is actually the same as the if structure, the second output is the same as the for structure in else, and the third output statement is in the for structure in else. Three outputs are in different structural blocks, so the output is different. I think of a joke. the general idea is that to learn python, we need a vernier caliper. haha, is it Head First Python? Therefore, it is better not to use the built-in python IDLE, which is too difficult to use. if a code block is accidentally typed incorrectly, it will almost all be modified. It is also difficult to control and observe indentation. You need to carefully repeat the topic. Pythonpython depends on the indentation logic. the indentation logic is naturally different, which is equivalent to the C language {}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service