M
M
Matvey2021-12-12 20:18:19
Python
Matvey, 2021-12-12 20:18:19

Is it possible to make all 4 words not equal to each other?

There is a list of words of 10 words.
I want to generate 4 words from this list, but at the same time, so that they do not repeat. I did it
through random.choice (words), but how to avoid repetitions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-12-12
@SoreMix

random.sample(words, 4)
https://docs.python.org/3/library/random.html#rand...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question