I didn’t get why is yrange not consumable multiple times while zrange is in python iteration protocol video ?
Iteration protocol
hey @stutijain578 ,
it is because on iterating over yrange it results in an output value and hence when we reach the end of that range it stops and cannot be used further , whereas when we iterate over zrange , it generates an another iterator class every time (which works the same as yrange ).
for example in zrange:
if we iterate it 10 times ,
it means that we are generating 10 iterators and each of these iterators can create a list of values from 1-10 , hence we get 10 lists of 1 - 10.
where as if we had iterated over yrange, then in 1 iteration we would have reached the end value in range specified and cannot iterate over it further.
I hope this would have resolved your doubt.
Thank You and Happy Learning .
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.