Added introduction.md for loops.

This commit is contained in:
BethanyG
2021-04-25 20:44:16 -07:00
committed by BethanyG
parent 3fbf7377bb
commit 29ca91e744
2 changed files with 4 additions and 3 deletions

View File

@@ -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:

View File

@@ -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
```