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 Collections (Retired) Slices Slice Functions

Hey, I'm confused on what a 'iterable' is (What does it mean?)

what exactly this challenge is asking me to do? I haven't a clue what this challenge is asking for 1st i am not completely sure what a iterable is.

Please help when understand this challenge thanks

3 Answers

An interable is an object like a list, string, or tuple that contains other objects that it can return one at a time.

If you've used a for in loop, you can be said to have iterated over an object.

It seems like the challenge wants to you write a method that takes in an iterable object and return the first four things in it. So if you passed it the string "Oliver Twist", you'd get back "Oliv" and if you passed it the list [1, 2, 3, 4, 5, 6], you would get back [1, 2, 3, 4]

Brandon Wall
Brandon Wall
5,512 Points

To iterate is a verb, in our case i think the third definition is most appropriate (taken from Dictionary.com): To operate or be applied repeatedly, as a linguistic rule or mathematical formula. Another definition is: To do something over again or repeatedly.

So an iterable is something that we may iterate over, a collection of things as stated above, lists, strings, tuples, dictionaries, sets. When using a for in loop we are iterating over our collection which is our iterable.

Think of an iterable as a collection of things that we may sort through one at a time, these collections come in different forms but they are collections nonetheless and therefore are iterables.

Thanks!