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.
Question on the Random Choices Objective
I keep getting the error "Bummer! Expected 5 items, got 10." I have tried sending empty variables, declaring them outside the function, and everything else I can think of. When I run this script I get a something like "['a', 'b', 'c', 'a', 'c']" as my solution.
What is going wrong? I have had this problem before where the challenge program was sending things in for me, but I can never figure out what to change to get it to work correctly. Is there any way I can get the Challenges to show me debugging information?
#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. import random list =  def nchoices(str,n): for x in range(n): list.append(random.choice(str)) return list print(nchoices(('a','b','c'),5))
EDIT: I solved it. Should have realized it was running the function for me, but my question about a debugger still stands
import random def nchoices(str,n): list =  for x in range(n): list.append(random.choice(str)) return list
Steven Parker218,635 Points
Good job on resolving your issue!
I don't think you can debug from within the challenge, but you can always copy the challenge code over to the workspace, and experiment with it there.