Skip to content

Commit 580179e

Browse files
committed
Iterator section rearranged
1 parent 5d9800a commit 580179e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,6 @@ Iterator
168168
<iter> = iter(<function>, to_exclusive)
169169
```
170170

171-
#### Skips first element:
172-
```python
173-
next(<iter>, None) # default of `None` avoids exception for empty <iter>
174-
for element in <iter>:
175-
...
176-
```
177-
178171
#### Reads input until it reaches an empty line:
179172
```python
180173
for line in iter(input, ''):
@@ -188,6 +181,17 @@ for line in iter(partial(input, 'Please enter value: '), ''):
188181
...
189182
```
190183

184+
### Next
185+
**Returns next item. If there are no more items it raises exception or returns default if specified.**
186+
<el> = next(<iter> [, default])
187+
188+
#### Skips first item:
189+
```python
190+
next(<iter>, None)
191+
for element in <iter>:
192+
...
193+
```
194+
191195

192196
Generator
193197
---------

0 commit comments

Comments
 (0)