A control flow
Sequential structure: statement queue according to the order determined before and after the next statement to be executed
Conditional branch structure, based on the current situation to the next statement in the selection position
Loop structure: continuously executes a series of statements
Two iterative loop for
Definition 1
Iterables represents individually extracted from the data object assigned to the data item "loop variable"
It contains many types, such as strings, lists, tuples, dictionaries, collections, etc.
2 format
for <loop variable> in <iterables>:
<Statement block 1>
And in the reserved words for composition, complete traversal of all elements of the end of the beads, each cycle, obtained element into the loop variable
And execute a block of statements
Counting cycle, the digital sequence generated by traversing range function, a circulating
for i in range(N):
<Statement block>
3 Examples
Examples
Range function. 4 (with the range for general use in combination)
Three loop while
Definition 1
A circulation operation controlled conditions
while <Condition>:
<Statement block>
The statements repeatedly, until the end when the conditions are not satisfied
2 Examples
Four break statement continue statement
Definition 1
Using only the inner loop, may be configured for, while using
Acting on the nearest cycle
It is a break out of the current cycle, and ends the present cycle of layer
continue is to skip the rest of the loop and then the next cycle
2 Examples
Advanced Usage five cycles