The source code is
return[[“What color is the daytime sky on a clear day?”, “blue”],
[“What is the answer to life, the universe and everuthing?”, “42”],
[“What is a three letter word for a mouse trap?”, “cat”,]]
question = question_and_answer answer = question_and_answer given_answer = input(question) if answer == given_answer: print("Correct") return True else: print("Incorrect, correct was:", answer) return False
if len(questions) == 0:
print(“no questions were given.”)
return index = 0 right = 0 while index < len(questions): if check_question(questions[index]): right = right + 1 index = index + 1 print("you got", right * 100 / len(questions),\ "%right out of", len(questions))
I am very stuck at ‘if check_question(questions[index]):’
The book I am learning from doesn’t go over this part at all. Does ‘[index]’ here refer to the local variable index? Or is this the function of indexing? If so I thought that was written only like list.index().
Please correct anything I said wrong, I’ll take all the help I can get! Thank you!