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 (Retired) Dungeon Game Random Choices

Baffling error message when testing nchoices().

The code challenge is pretty straight forward. In my test in python on my own machine, a simple function works.

I begin with the obvious:

def nchoices(anIterable, n):

# rest of code goes here

However, the evaluator prints "Bummer, can't find nchoices()"

Not sure what's happening ++++++++++++

After writing the function correctly in a local Python environment, I neglected to import random, when running it in treehouse.

If I had done this in a local environment, Python would have complained with

NameError: name 'random' is not defined

Which makes sense, whereas the Treehouse error message did not 8-(

2 Answers

Hi Peter,

Did you import the random module?

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

There's nothing in your nchoices function, so it's causing the interpreter to break and not actually register your function.