Skip to content

Commit

Permalink
Merge pull request #46 from elliewix/patch-10
Browse files Browse the repository at this point in the history
adding info on using range for repetition
  • Loading branch information
richyvk authored Jun 4, 2017
2 parents 478d836 + 7d73f41 commit 109b28b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions _episodes/12-for-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,26 @@ a range is not a list: range(0, 3)
~~~
{: .output}

## Or use `range` to repeat an action an arbitrary number of times.

* You don't actually have to use the iterable variable's value.
* Use this structure to simply repeat an action some number of times.
* That number of times goes into the `range` function.

~~~
for number in range(5):
print("Again!")
~~~
{: .python}
~~~
Again!
Again!
Again!
Again!
Again!
~~~
{: .output}

## The Accumulator pattern turns many values into one.

* A common pattern in programs is to:
Expand Down

0 comments on commit 109b28b

Please sign in to comment.