Is there a way to prevent an object in a list from printing more than once?

So I’m creating a python code to randomly pick one question out of all the questions I have in my list. When I run the code, it randomly picks one question out of the list of about 200 questions and shows it to me. I want to answer this question and then move on to the next one. However, I don’t want to keep getting the same question after I’ve already answered it. Is there a any way to make sure that once a question has been printed, it is removed from the list so it can’t appear again? Because I could have gone through all but one question and have to go through multiple other questions I’ve already answered before I get to the particular one I haven’t answered. So is there a way I can make sure no question can be printed more than once?(I don’t want to print all questions using random.sample k=200 as I don’t want to know what question is coming next.) Any response will be deeply appreciated.

My code currently looks like this: import random

questions= [ 'define math', 'define french', 'define english', ]

results = random.sample(questions, k=1) print(results)

Except with 200 questions

Read more here:

Content Attribution

This content was originally published by SUPERFROG2 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: