In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people have no idea about how to use the else statement in the loop in Python. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. Else statement module in the loop
1. The else statement inside the loop, if used with the If statement, is the normal flow of the if statement.
2. The else statement outside the loop is directly used with the loop statement while or for, then it means that if the loop statement has not been jumped out of the break, the else statement connected to the outside of the loop will be executed.
II. Supplement: the use of semicolons
It is to separate the function of our variables, to distinguish what statements are used, to use them only when multiple statements appear in one line. By default in Python, a line of code is thought of as a statement.
Third, supplement range function to pass parameters.
If a value is passed in by default, then the default starting position is 0, which is still a half-open and semi-closed interval, and the last value is not included.
Note: the else statement module used with the loop statement is mutually exclusive with the break in the loop statement.
IV. Summary and emphasis
1. Understand the supplement of range function
2. Understand the supplement of semicolons
3. Master the combination of else statement and while sentence
4. Master the combination of else statement and for sentence
This section of the knowledge source code 1 while else is used with the source code:
Xerox 9: 10
While x
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 214
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.