I have a question for python coding
I am very new to coding my apologies if my lingo is off or hard to understand
I am trying to learn how to create a multiple question test where the user can only input a string as the input in the for loop, and if they put any other datatype it restarts the for loop ( asks the question again)
Here is what I have
class question:
def __init__(self, prompt, answer):
self.prompt = prompt
self.answer = answer
question_prompt = [
"what is 2+2? \n a 3 \n b 4 \n c 5 \n d 6 \n input answer here ",
"what is 3+3? \n a 4 \n b 5 \n c 6 \n d 7 \n input answer here ",
"what is 10-2?\n a 7 \n b 9 \n c 8 \n d 6 \n input answer here "
]
questions = [
question(question_prompt[0],"b"),
question(question_prompt[1],"c"),
question(question_prompt[2],"c")
]
def run_test(questions):
score = 0
for question in questions:
answer = str(input(question.prompt))
if answer == question.answer:
score += 1
## if xxxxxxx(): ## This is the line I need help with I want to check if the input is a string and if not print("Wrong input option please enter a letter")
print("you got " + str(score) + "/" + str(len(questions)))
run_test (questions)
Thank you in advance for the help :)