Skip to content

Commit

Permalink
Merge pull request #25 from elliewix/patch-2
Browse files Browse the repository at this point in the history
changing the text around iterable variable names
  • Loading branch information
richyvk authored Jun 4, 2017
2 parents cf2bf87 + 3c67bfd commit 478d836
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions _episodes/12-for-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ for number in [2, 3, 5]:
* The loop variable, `number`, is what changes for each *iteration* of the loop.
* The "current thing".

## Loop variables can be called anything.

* As with all variables, loop variables are:
* Created on demand.
* Meaningless: their names can be anything at all.

## Loop variable names follow the normal variable name conventions.

* Loop variables will:
* Be created on demand during the course of each loop.
* Persist after the loop finishes.
* Use a new variable name to avoid overwriting a data collection you need to keep for later
* Often be used in the course of the loop
* So give them a meaningful name you'll understand as the body code in your loop grows.
* Example: `for single_letter in ['A', 'B', 'C', 'D']:` instead of `for asdf in ['A', 'B', 'C', 'D']:`
~~~
for kitten in [2, 3, 5]:
print(kitten)
Expand Down

0 comments on commit 478d836

Please sign in to comment.