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

what would be the code for this

Plz tell me what would be the code for this i mean the slice for this the starting stoppin and stepping one

slices.py
def first_4(iterable):
    return iterable[:4]
def forst_and_last_4(iterable):
    return iterable[:4:-1]

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,426 Points

The challenge error message give a clue to the first issue: "Can't find first_and_last_4". If it were due to a syntax error you would get "Bummer!". This error means the code compiles correctly but the function isn't found. :point_right: time to check for spelling errors!

Fixing the spelling error, the code isn't correct. Since you've pass Task 1, you should know how to find the last 4 characters. Using this knowledge you can combine the two solutions using string concatenation by including a + sign.

Post back if you need more help. Good luck!!