Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (Retired) Dungeon Game Random Choices

Can somebody rephrase the question, without giving the solution?

I don't understand the question or task, making it impossible to solve. So can somebody rephrase this question, without giving the solution?

Create a function named nchoices() that takes an iterable and an integer. The function should return a list of n random items from the iterable where n is the integer. Duplicates are allowed.

1 Answer

The challenge is asking you to take an iterable and an integer (exactly as it said), and return a list of n (the integer is n) random numbers from the iterable.

Here are the steps to take:

  1. Add a random value from the iterable to a list.
  2. Repeat that n times (where n is the integer)

Good luck! ~alex

EDITED