I have a dictionary:
categories = {
"fruits" = ['banana', 'apple', 'strawberry', 'grape', 'watermelon', 'mango'],
"countries" = ['Canada', 'Brazil', 'Ghana', 'Cuba', 'Japan', 'Germany', 'France'],
"colors" = ['green', 'brown', 'pink', 'yellow', 'red', 'grey', 'blue']
}
And I need a function that returns a category/key (like 'colors') and 3 different words from one single key/category (like 'brown', 'pink', 'yellow'). So I wrote:
category = random.choice(list(categories))
print(category)
words = random.choice(categories[category]), random.choice(categories[category]), random.choice(categories[category])
print(words)
But sometimes it returns the same words. For example:
colors
('brown', 'blue', 'blue')
What can I do to make sure it will always return me 3 different words?