Added introduction.md for loops.
This commit is contained in:
@@ -12,9 +12,6 @@ The keywords `break`, `continue`, and `else` help customize loop behavior.
|
||||
|
||||
```python
|
||||
|
||||
# Lists are considered "truthy" in a boolean context if they
|
||||
# contain one or more values, and "falsy" if they are empty.
|
||||
|
||||
>>> placeholders = ["spam", "ham", "eggs", "green_spam", "green_ham", "green_eggs"]
|
||||
|
||||
>>> while 'eggs' in placeholders:
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
There are two looping constructs.
|
||||
`while` loops for _indefinite_ (uncounted) iteration and `for` loops for _definite_, (counted) iteration.
|
||||
The keywords `break`, `continue`, and `else` help customize loop behavior.
|
||||
`range()` and `enumerate()` help with loop counting and indexing.
|
||||
|
||||
|
||||
`while` loops continue to exectute as long as the loop expression or "test" evaluates to `True`, terminating when it evaluates to `False`.
|
||||
|
||||
@@ -17,3 +19,5 @@ while expression:
|
||||
for item in sequence:
|
||||
set_of_statements
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user