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!
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
fahad lashari6,771 Points
What am I missing from the code?
Hi I tried the code in the workspaces and in delivered the desired result from the question. However I am not sure as to exactly what the question requires?
I would appreciate any help.
def first_4(string): return string[:4] def first_and_last_4(string): new_string = string[:4] + string[-1:-4:-1] return new_string
Steven Parker225,712 Points
You may have misinterpreted the challenge.
You're really close, but the challenge wants the first 4 and last 4 items, in the original order.
Your code above will return the right items, but the last 4 will be reversed.
Jasmeet Singh3,309 Points
Try this code. It might help
new_string = string[:4] + string[-4:] return new_string