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 trial

Python Python Collections (2016, retired 2019) Dungeon Game random.sample

igor corrales
igor corrales
2,474 Points

I don't know what is wrong .....

When I run my code in the python console with get_locations(3) I get three random numbers ....so I think this is what the challenge is ask for !!

what is the problem then ??

sample.py
import random

def get_locations(cells):
    c = list(range(0, 15))
    d = random.sample(c,cells)
    return d

1 Answer

Jerson Otzoy
Jerson Otzoy
1,532 Points

Hello, the description says the cells argument already contains the elements and we only need 3 of them

import random

def get_locations(cells):   
    d = random.sample(cells, 3)
    return d