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 trialyannis sousanis
7,199 Pointsneed help here too...
I see this right but it isnt
def first_4(b)
return b[0:4]
2 Answers
Greg Kaleka
39,021 PointsHi Yannis,
You've got the right idea - you just left off the colon after your function declaration! Syntax will get you . Always look for typos first. They trip up everyone.
def first_4(b):
return b[0:4]
Note you can also leave off the zero at the beginning of a slice:
def first_4(b):
return b[:4]
Cheers
-Greg
Ari Misha
19,323 PointsHiya Yannis! Try this code for reference :
def first_4(words):
return words[:4]
Greg Kaleka
39,021 PointsHi Ari,
Thanks for helping out in the Community. When answering questions, it's always best to give an explanation. Giving students the answers without explanations doesn't help them learn!