I want to grab a random items in a list using random.choices()
, but I don't need to grab some multiple items.
Example:
import random
mylist = ['python', 'c++', 'html', 'CSS', 'JavaScript']
print(random.choices(mylist, k=4)
in sometimes it returns this output:
['python', 'html', 'JavaScript', 'JavaScript']
So I want to remove the duplicated JavaScript, so it remains only one JavaScript and replace the duplicated one with a new item
['python', 'html', 'CSS', 'JavaScript']