Welcome to the Treehouse Community
Looking to learn something new?
Kang-Kyu Lee52,045 Points
my answer doesn't pass..
import random def nchoices(an_iterable, choose_num): list_of_items =  for _ in range(choose_num): pop_item = an_iterable.pop(random.randrange(len(an_iterable))) list_of_items.append(pop_item) return list_of_items iterable = [1,2,3,4,5,6,7,8,9] integer = 4 nchoices(iterable,integer)
Maybe I did it wrong, only I couldn't figure what it is... it works at workspace
Kenneth LoveTreehouse Guest Teacher
It's not that there's anything that says to allow duplicates, nothing says to not allow duplicates, so you shouldn't assume that.
Hi kang kyu lee,
I don't think the challenge is specific enough on this but I think it wants the solution to allow duplicates. Whereas, you're popping off items and shortening the iist and making sure the same one isn't picked twice.
I changed your code so that instead of popping off the item at that random index you access the item at that index and it passed the challenge.
I have not been through this course so I don't know if there is something in the videos that would have hinted that you should allow duplicates here.