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 trialDaniel Kraft
1,196 PointsStuck on Import challenge in Python Basics
For task 2 of the challenge, whenever I try to define a function, it tells me that task 1, where we import the random library, is invalid. I don't understand why this is happening, the code has not been changed at all, there is just further code written in the lines beneath it.
import random
def random_member(mylist)
return len(mylist)
1 Answer
White Moses
3,589 PointsThat is why you forgot this ':' very important symbol after defining function. def random_member(mylist):
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsThe colon identifies the beginning of a code block, that is, a set of further indented code statement(s).