Różnica między generatorem a iteratorem w Pythonie
* difference between generator and iterator in python
------------------------------------------
Iterator uses iter() and next() functions
Generator uses yield keyword
------------------------------------------
* Iterator
iter_list = iter(['Geeks', 'For', 'Geeks'])
print(next(iter_list))
print(next(iter_list))
print(next(iter_list))
* Generator
def sq_numbers(n):
for i in range(1, n+1):
yield i*i
a = sq_numbers(3)
print("The square of numbers 1,2,3 are : ")
print(next(a))
print(next(a))
print(next(a))
ASHABB