0

What is exact diffrence between iterator and generator?

explain one example of iterator and generator? why using iterator and generator? when using?

18th Dec 2017, 3:57 PM
lokesh reddy
lokesh reddy - avatar
3 odpowiedzi
+ 1
Iterators is sth you use to iterate aka LOOP through an object(could be a list, string, dict, tuple,etc) A generator is an instant way to create values WHICH doesn’t take up memory unless you call it as opposed to a list, tuple, dict,..
18th Dec 2017, 5:04 PM
monotom
monotom - avatar
0
give one example?
18th Dec 2017, 3:59 PM
lokesh reddy
lokesh reddy - avatar
- 1
Iterators iterate over something existing. Generators generate something new.
18th Dec 2017, 3:59 PM
Jeremy
Jeremy - avatar