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 trialMathew Yangang
4,433 Pointsrandom.sample
I keep getting couldn't find get locations errors
import random
def get_locations(cells):
random.sample(x,y)
pass
return get_locations()
return get_locations()
return get_locations()
1 Answer
Dave Harker
Courses Plus Student 15,510 PointsHi Mathew Yangang,
You can only process a single return from a function but I can see what you were trying to achieve there. Since that isn't an option however we can use the random.sample function from Python random, which returns a list.
From the python documentation found here: Python 3 - Random
random.sample(population, k)
Return a k length list of unique elements chosen from the population sequence or set. Used for random sampling without replacement.
So with that in mind, you could try something like:
return random.sample(cells, 3)
Keep on coding!
Dave
P.S. You can just delete that pass
from the challenge ... not sure why they put that there.