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 trialmamadou diene
Python Web Development Techdegree Student 1,971 PointsAlright, these tasks are a bit harder than the others so far in this course but I know you can do them! In this first o
i need a little push here please
def first_4():
return first_4(0:5)
3 Answers
Stuart Wright
41,120 PointsOk you've made the appropriate corrections for the second two points on my list above, so it's just the first one that needs fixed. To better explain what I mean by passing a parameter to your function, here is a very basic function which simply returns the parameter with no changes:
def my_function(my_parameter):
return my_parameter
The difference between the above and your function is that you should only return the first 4 elements of your parameter. Does that make sense?
Stuart Wright
41,120 PointsHere are three hints to get you started:
- your function needs to have a parameter which is an iterable, and you need to return the first four items of that iterable.
- you need to use square brackets rather than parentheses for slicing.
- the slice starting at 0 and ending before 5 is the first 5 elements, not 4.
mamadou diene
Python Web Development Techdegree Student 1,971 PointsHere is the corrections:
def first_4(1, 2, 3, 5, 7, 9, 3): return first_4[0:4]
mamadou diene
Python Web Development Techdegree Student 1,971 Pointsmamadou diene
Python Web Development Techdegree Student 1,971 PointsIt worked!! thank you