Skip to content

Commit 7a57e7b

Browse files
committed
iteration inter
1 parent 5972a02 commit 7a57e7b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

newcodes/answers/q67.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
4+
class ReverseRange:
5+
def __init__(self, n):
6+
self.n = n
7+
8+
def __next__(self):
9+
if self.n == 0:
10+
raise StopIteration
11+
self.n -= 1
12+
return self.n
13+
14+
def __iter__(self):
15+
return self
16+
17+
for i in ReverseRange(9):
18+
print(i)

0 commit comments

Comments
 (0)