I'm trying to validate some user input. I am creating a multi-answer quiz, which allows the user to answer a,b,c or d. I am trying to validate the user input, so if they were to enter nothing or and other letters it would pop allow them to answer the same question again. However when I run my code, if the user was to insert "g" for example, it would show "you are wrong" in the terminal and move onto the next question.
def quiz_game():
questions_num = 0
score = 0
for key in questions:
print("...................")
print(key)
for x in answers[questions_num]:
print(x)
guess = input('Enter a, b, c or d: ')
validate_input(input)
if answer_input(guess, questions_num):
print('Your answer is correct')
questions_num += 1
score += 1
else:
print('Your answer is wrong')
questions_num += 1
points(score)
def validate_input(guess):
guess = ('Enter a, b, c or d: ')
while not guess:
print('Enter a, b, c or d: ')