Skip to content

Commit 562bc51

Browse files
committed
explain iterables
1 parent bc1d7e1 commit 562bc51

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

basics/loops.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ Or if we just want to clear a list, we can use the `clear`
275275
>>>
276276
```
277277

278+
Later we'll learn that for loops are not actually limited to lists.
279+
There are many other things we can for loop over. Things that can be for
280+
looped over are called **iterables**.
281+
278282
If you're using Python 3.2 or older you need to use `stuff[:]` instead
279283
of `stuff.copy()` and `stuff[:] = []` instead of `stuff.clear()`.
280284
`stuff[:]` is a slice of the whole list, just like `stuff[0:]`.
@@ -285,6 +289,7 @@ of `stuff.copy()` and `stuff[:] = []` instead of `stuff.clear()`.
285289
- While loops repeat something as long as a condition is true, and
286290
they check the condition only in the beginning.
287291
- For loops can be used for repeating something to each item in a list.
292+
- An iterable is something that can be for looped over.
288293
- The `break` keyword can be used to interrupt the innermost loop at
289294
any time.
290295

0 commit comments

Comments
 (0)