I was wondering how I could fix a bug in my program. Basically, I have this short quiz program that's supposed to ask users a series of questions from a list they inputted previously (pickle
loads these from a previous part of my code in the example below) in a randomized way, but the program will sometimes repeat the same question, which I don't want to happen.
I've looked on this site, but I could not understand the answers to questions similar to mine.
def quiz():
import pickle
import random
import os
os.system('cls')
a = pickle.load(open("quiz.dat", "rb")))
random.shuffle(a)
#loads questions ans answers from previous section of program
for b in a:
print(b["question"])
response = input("What was the answer? : ")
if (response == b["answer"]):
print("Good Answer!")
else:
print("Wrong answer...")
print("The right answer was", b, ".")
print("Quiz is now over.")