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 trialMark Casavantes
Courses Plus Student 13,401 PointsWhy does Task 1 no longer pass? How can this be prevented? Also what am I doing wrong?
This is from Python Collections Challenge 3 of 3.
interable = (range(1,20))
def first_4(iterable):
return iterable[:4]
def odds(iterable):
return iterable[1::2]
def first_and_last_4(interable):
return interable[:4] + [-4:]
1 Answer
Dan Johnson
40,533 PointsYou forgot to specifiy the list you're slicing for the [-4:]
so just tag it on:
def first_and_last_4(iterable):
return iterable[:4] + iterable[-4:]
Mark Casavantes
Courses Plus Student 13,401 PointsGood Afternoon Alex and Dan,
Thank you for your help.
Alex Martini
5,913 PointsAlex Martini
5,913 PointsI don't know Python, so I'm not sure if your code is correct, but I've had this issue with the challenges before. Sometimes my prior tasks no longer pass even though everything is correct. It's as if the back end gets "stuck" on the prior task, even though you are seeing the first task. Refreshing the page will correct the issue (you might want to copy your code as it will be erased)..
Hope that's it.