Python-programming-exercises
Python-programming-exercises copied to clipboard
Q20: Problem is to provide class, answer is a generator function
As in topic: Problem is to provide class, answer is a generator function You should change "Define a class with a generator which can iterate the numbers" to "Define a generator function which can iterate the numbers" Or change soultion to provide class with iter() and next() for 2.7 or iter() and next() for 3.0+
n=input() def putNumbers(n): i=0 num=int(n) while i<num: j=i i=i+1 if j%7==0: yield j
print(list(putNumbers(n)))