Browse Source

Iterators

pull/3/head
Jure Šorn 6 years ago
parent
commit
cc85472b95
1 changed files with 2 additions and 2 deletions
  1. 4
      README.md

4
README.md

@ -406,7 +406,7 @@ lambda <argument_1>, <argument_2>: <return_value>
[i+1 for i in range(10)] # [1, 2, ..., 10]
[i for i in range(10) if i>5] # [6, 7, ..., 9]
{i: i*2 for i in range(10)} # {0: 0, 1: 2, ..., 9: 18}
(x+5 for x in range(0, 10)) # (5, 6, ..., 14) -> Generator
(x+5 for x in range(0, 10)) # (5, 6, ..., 14) -> Iterator
```
```python
@ -818,7 +818,7 @@ lock.release()
Itertools
---------
**Every function returns a generator and can accept any collection. If you want to print an output of generator, as in examples, you need to pass it to the list() function.**
**Every function returns an iterator and can accept any collection and/or iterator. If you want to print the iterator, you need to pass it to the list() function.**
```python
from itertools import *

Loading…
Cancel
Save