if Statements
for Statements
The range() Function
If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy.
It is possible to let the range start at another number, or to specify a different increment (even negative; sometimes this is called the ‘step’):
To iterate over the indices of a sequence, you can combine range() and len() as follows:
break and continue Statements, and else Clauses on Loops
Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement
Reference: https://docs.python.org/2/tutorial/
for Statements
The range() Function
If you do need to iterate over a sequence of numbers, the built-in function range() comes in handy.
It is possible to let the range start at another number, or to specify a different increment (even negative; sometimes this is called the ‘step’):
To iterate over the indices of a sequence, you can combine range() and len() as follows:
break and continue Statements, and else Clauses on Loops
Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement
Reference: https://docs.python.org/2/tutorial/
No comments :
Post a Comment