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 trialNicholas Hattwick
2,697 PointsPython collections: first_4
I'm not sure what I'm doing wrong. Any advice would be appreciated. Thanks.
list=range(6)
def first_4(list):
return list[0:4]
2 Answers
Justin Iezzi
18,199 PointsHi Nicholas,
You don't need to create the list for this code challenge.
Just -
def first_4(list):
return list[0:4]
Should pass the step. Try it out. :)
William Li
Courses Plus Student 26,868 Pointslist is a built-in function's name in Python, please refrain from using it as variable/parameter name, not only it's bad practice to do so, it can cause your program to have unpredictable behavior.
def first_4(li):
return li[0:4]
this would be fine.
Nicholas Hattwick
2,697 Pointsthanks, I'll keep that in mind.
Nicholas Hattwick
2,697 PointsNicholas Hattwick
2,697 PointsPerfect, thank you very much!