I'm trying to randomized some words in Python, but I get lines with repeated terms. How can I avoid it?
My code:
words = ['blue,', 'orange,', 'yellow,', 'white,','pink,']
list=[]
for i in range(90):
r = ''.join(random.choices(words, k=random.randint(1, 5)))
if r not in list: list.append(r)
What I get:
orange,white,orange,white,blue, <-- Here Orange & white are twice
Thanks!