Loops: How Do I Repeat Program Instructions Efficiently?
摘要
In this chapter we deal with the efficient repetition of the same program instructions. In this way, many complex tasks can be solved elegantly. Like most programming languages, Python knows both counting (for) and conditional (while) loops for this purpose. A Python peculiarity are the list comprehension expressions based on the for loops, with which you can write the generation of lists very compactly.