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 trialPrabhath Pillai
2,740 PointsWhat is an "iterable"?
I've been given these instructions:
"Make a function named first_4 that accepts an iterable as an argument and returns the first 4 items in the iterable."
What exactly is an "iterable"? Does this mean I should create a for loop and slice it?
first_4 =
1 Answer
Emil Rais
26,873 PointsAn iterable is a datatype that can be iterated - using a for loop. list and str are both examples of iterable datatypes.
You should create a function using the def keyword. It should be named as outlined in the challenge description. It should accept a single parameter and you should return the first four items of the iterable; slicing would indeed be an excellent way to go about that.
Prabhath Pillai
2,740 PointsPrabhath Pillai
2,740 Pointsthank you emil, you legend!