I am wanting to use random.randint() to make a random quiz using list. As of now my code works well but there are times where it will ask the user a question twice instead of randomising all questions. This happens only sometimes. How do I avoid this by only using random.randint? I can only use this and .del() as this is what I am taught in my course.
import random
print("Welcome to Te Reo Maori Quiz!!!")
print("\nAnswer the questions with single Maori words")
Q = ['A challenge laid down in chant and dance:',
'What is "Sun" in Maori:',
'Something you eat to fill your belly:',
'Type in the Maori word for "cave":',
'Traditional Maori food cooked in an earth oven:',
'Ma is white, whero is red, kakariki is green, pango is black. What else is black?:',
'its getting ... in here, so take off all your clothes:',
'What does Kia ora mean?:',
'What does ka pai mean?:',
'What does kei te peha koe mean?:',
'What is the Maori phrase for "what is your name?:',
'What does hikoi mean?:',
'What is a waiata:',
'What is the the Maori word for stomach?:',
'What does mahi mean?',
'What is the maori word for wait?:',
'if something was nui, then it would be what?:',
'What does Haere mai mean? (hint: it starts with "w"):',
'What does nau mai mean?:',
'What does tangi mean?:',
]
A = ['haka', 'ra', 'kai', 'ana', 'hangi', 'mangu', 'wera', 'hello', 'good', 'how are you', 'ko wai to ingoa', 'walk',
'song', 'puku', 'work', 'taihoa', 'big', 'welcome', 'welcome', 'funeral'
]
points = 0
current = 0
quiz = 0
while (quiz < 5):
question = Q[current]
answer = A[current]
question = input("\nQ" + str(quiz + 1) + ". " + Q[current])
if question.lower() == answer.lower():
points = points + 20 #adds points if the answer is correct
current = current + 2
print("Correct Answer!")
else:
print("Incorrect answer. The correct answer is:", A[current])
###points = points - 10
###current = current + 2
#quiz = quiz + 1
###if points < 0:
###points = 0
print("\nEnd of Quiz.")
print("Your score: %", points, sep = "")
I expect my code to produce 5 random questions at every iteration.