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

Alejandro Loja
Alejandro Loja
6,541 Points

I have been stuck on this problem for 30 mins, what am I doing wrong?

Thanks in advance

import random

def get_locations(cells):
for i in range(cells.length):
    value = random.sample(cells,3)
        return value

1 Answer

Umesh Ravji
Umesh Ravji
42,386 Points

Hi Alejandro, you actually have the code you need, but you need to remove the loop (and the pass) :)

Just for future reference, indentation is extremely important in python, for your loop to be within your function, it would have to be indented.

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

why did the problem include "pass" that you have to remove after the first line of your code?