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

Travis John Villanueva
Travis John Villanueva
5,052 Points

Help with the proper output? What is the desired outcome?

I think i nailed this objective as ive test it in worskpaces. It was previously as

def x(raw): raw=list(raw) print(raw[:4])

but im making a wild guess now that is why its 3.

What is the desired output?

slices.py
def first_4(raw):
    raw=list(raw)
    print(raw[:3])

1 Answer

Grace Kelly
Grace Kelly
33,990 Points

Hi Travis, you're almost there! Just a couple of minor things:

  1. To get the first 4 items in a list you use [:4] which goes from index 0 and moves 4 places.
  2. The challenge requires to return the result, not to print it :)

Hope that helps!!