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

Abdul Kader
Abdul Kader
3,504 Points

I dont understand the question. How do you define an utterable which can be anything?

nil

slices.py
def first_4():
    num = [1,2,3,4,5]
    return num[:4]

print(first_4())

1 Answer

The first_4 function take any iterable as a argument like so: def first_4(arg): # arg can be any iterable # code to return first four items

Then you call it like so: print(first_4([1,2,3,4,5]))