What is the iterable? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the iterable?

23rd May 2018, 9:48 PM
Omar
Omar - avatar
5 Answers
+ 1
Something you can loop through.
23rd May 2018, 9:52 PM
Akib
Akib - avatar
+ 1
A list for example
23rd May 2018, 11:00 PM
Max
Max - avatar
0
like what
23rd May 2018, 10:03 PM
Omar
Omar - avatar
0
what is the meaning of iterable and how can list be an iterable??
24th May 2018, 9:56 AM
Omar
Omar - avatar
0
An iterable is any object, not necessarily a data structure, that can return an iterator (with the purpose of returning all of its elements). An iteration is a object that has the function __next__() which gives back the next element. If you use a for loop to go through a list like for example for x in list: do_stuff_here() It gets the iterator from list and uses __next__() every loop iteration to put the next element in x and stops looping if __next__() returns no object You can use iterators to use the for ... in ... Syntax in your Own classes. See this for more information: http://nvie.com/posts/iterators-vs-generators/
24th May 2018, 10:37 AM
Max
Max - avatar