alexgreene / WikiQuiz

Generates a quiz for a Wikipedia page using parts of speech and text chunking.
MIT License
803 stars 58 forks source link

Prevent duplicate questions from being selected #11

Closed c-w closed 7 years ago

c-w commented 7 years ago

The random.choice method performs sampling with replacement. This means that the get_ten_random method could return the same question more than once which is not a great user experience.

Using random.sample (part of the standard library since 2.3 so we can for sure assume that it's available), we perform sampling without replacement so that we prevent any possibility of duplicate questions.