Python Python Collections Dungeon Game random.sample

Mathew Yangang
Mathew Yangang
Python Web Development Techdegree Student 4,433 Points


I keep getting couldn't find get locations errors
import random

def get_locations(cells):


    return get_locations()
    return get_locations()
    return get_locations()

1 Answer

Dave Harker
Dave Harker
Pro Student 15,505 Points

Hi 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 :dizzy:

P.S. You can just delete that pass from the challenge ... not sure why they put that there.