Skip to content

Commit 1b8ae1f

Browse files
authored
Updated Question 20 code
Implmented solution as stated in code using class.
1 parent 54eed14 commit 1b8ae1f

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

100+ Python challenging programming exercises for Python 3.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,21 @@ Consider use yield
562562
Solution:
563563

564564
```python
565-
def putNumbers(n):
566-
i = 0
567-
while i<n:
568-
j=i
569-
i=i+1
570-
if j%7==0:
571-
yield j
572-
573-
for i in reverse(100):
574-
print(i)
565+
class generator:
566+
567+
list = []
568+
def __init__(self, n):
569+
self.n = n
570+
571+
def listGenerator(self):
572+
for i in range(1, self.n):
573+
if i%7==0:
574+
self.list.append(i)
575+
print(self.list)
576+
577+
n = int(input())
578+
obj = generator(n)
579+
obj.listGenerator()
575580
```
576581

577582
### Question 21

0 commit comments

Comments
 (0)