Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python Data Types Index

can't understand iterable

can you give me a brief description of what is iterable i cannot understand it .please tell me .

4 Answers

Justin Noor
Justin Noor
3,692 Points

Hi Vikas Pal.

In simple terms, an iterable is any sequence of values that can be examined one by one, over and over again. For example if you recite the English alphabet you are iterating the alphabet.

Insofar as Python, iterables come in many forms, such as a list ['a', 'b', 'c', 'd'], a dictionary {'letter': 'a', 'b', 'c', 'd'}, or a string 'abcdefg'. Most iterables can be edited or manipulated, while some cannot (such as a tuple). Perhaps the most common way of iterating through a Python iterable is with a 'for loop'.

Let me know if that helps. Good luck!

can i know your facebook id to add you in friend

Hi Justin, The video said iterable means you can loop through . but what does this mean?

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hi Vikas,

The short answer -- an iterable is anything that can have it's individual items picked out. This can actually be any number of things.

For example, if you had a Dictionary with a bunch of colors in it, that dictionary would be an iterable because you could loop over and pull out each color individually.

I hope this helps some. If your still not sure on the meaning, you could give Google a shot to see other examples. (Hint: if you add "stack overflow" to the search request, you'll get some pretty good examples.)


jason tell me your facebook id so i send you friend request

From my personal research I think

Iteration is a general term for taking each item of something, one after another like what Justin and Vikas have said . Any time you use a loop(In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached) explicit or implicit, to go over a group of items, that is iteration.

In Python, iterable and iterator have specific meanings.

An iterable is an object that has an iter method which returns an iterator, or which defines a getitem method that can take sequential indexes starting from zero (and raises an IndexError when the indexes are no longer valid). So an iterable is an object that you can get an iterator from.

An iterator is an object with a next (Python 2) or next (Python 3) method.

Whenever you use a for loop, or map, or a list comprehension, etc. in Python, the next method is called automatically to get each item from the iterator, thus going through the process of iteration.

thank you all of you i understand it and i don't have any doubt.i understand it very far month but i forget to thank you and change the comment