and while using the for loop where is the object of the class
How yrange is acting both as iterator and iterable
Hello @avin99, yrange is acting as both becuase both of the function __
iter__
and __
next__
are defined in the range class so iter is making it iterable and next is making it iterator. It is because in iter it is returning self. But in zrange it is not so.
at 6:18 how object got created and used in for loop
__iter__
and __next__
are dunders in python. There are like inbuilt functions in python that provides the functionality to the object they are meant to. So by using both the functions we are providing yrange the functionality of both iterator and iterable.There are a lot of drunders you can read about them and what functionality they provide.