Skip to content

Commit

Permalink
Merge pull request #123 from ndporter/patch-1
Browse files Browse the repository at this point in the history
Use append instead of re-assigning full list
  • Loading branch information
chennesy committed Jun 27, 2024
2 parents 073418e + 02a238b commit 469ac23
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion episodes/for-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ We can call the loop variable anything we like, there must be a colon at the end
Loops are more robust ways to deal with containers like lists. Even if the values of the `odds` list changes, the loop will still work.

```python
odds = [1, 3, 5, 7, 9, 11]
odds.append(9)
odds.append(11)
print(odds)
for num in odds:
print(num)
```

```output
[1, 3, 5, 7, 9, 11]
1
3
5
Expand Down

0 comments on commit 469ac23

Please sign in to comment.