Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa698fe

Browse files
committed
added new content
1 parent 0e208af commit fa698fe

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

‎markdown-version/iterators-generators.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,22 @@ Iterator is an object that can be iterated upon. An object which returns data,on
66
### Iterable
77
An object which will return an Iterator when `iter()` is called on it.
88

9-
For example `"HELLO"` is an iterable but its not an iterator but `iter("HELLO")` returns an iterator.
9+
For example `"HELLO"` is an iterable but its not an iterator but `iter("HELLO")` returns an iterator.
10+
11+
### `NEXT()`
12+
When `next()` is called on an iterator, the iterator returns the next item. It keeps doing so until it raises a `StopIteration` error.
13+
14+
```python
15+
def custom_iter(iterable):
16+
iterator = iter(iterable)
17+
while True:
18+
try:
19+
print(next(interator))
20+
except StopIteration:
21+
print("END")
22+
break
23+
```
24+
25+
### Generators
26+
- Generators are iterators.
27+
- Generator can be created with generator functions

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /