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 (2016, retired 2019) Slices Slice Functions

This code works. why no passy pal?

The code below will return the first four items of whatever iterable is given to it and just pass anything not iterable. Is this challenge bugged?

slices.py
# return 1st four items from iterable
def first_four(iterable):
    try:
        return(iterable[:4])
    except TypeError:
        pass

1 Answer

Steven Parker
Steven Parker
229,952 Points

:point_right: Your function has the wrong name.

The challenge asks you to create a function named first_4, but your function is named first_four. Just give it the correct name to pass.

:information_source: As a general hint about challenges, it's a good idea to follow the instructions closely, and not improvise and add extra features. While it causes no problem here, in other challenges it may prevent your program from passing.

(Face-palm). Thanks Steven.