From 580179e353599461d8881437a8779e2c7cb92db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 5 Feb 2019 21:19:28 +0100 Subject: [PATCH] Iterator section rearranged --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3146c2a..11b4bac 100644 --- a/README.md +++ b/README.md @@ -168,13 +168,6 @@ Iterator = iter(, to_exclusive) ``` -#### Skips first element: -```python -next(, None) # default of `None` avoids exception for empty -for element in : - ... -``` - #### Reads input until it reaches an empty line: ```python for line in iter(input, ''): @@ -188,6 +181,17 @@ for line in iter(partial(input, 'Please enter value: '), ''): ... ``` +### Next +**Returns next item. If there are no more items it raises exception or returns default if specified.** + = next( [, default]) + +#### Skips first item: +```python +next(, None) +for element in : + ... +``` + Generator ---------