Python Dates and Times in Python Let's Build a Timed Quiz App The Quiz Class

Henry Lin
Henry Lin
11,636 Points

I don't get total_correct() at all!

In Quiz class, we have a answers = [] list which stores correct answers. Hence, I would assume that answers list looks like this [1, 10, 4, ....] a list of numbers. So When we want to check if user's answer is in the list, we just do for loop, and I don't get what the answer[0] does. answer is an integer, how come answer[0] works?

1 Answer

Steven Parker
Steven Parker
203,990 Points

The "answers" list is not actually the answers given. Each "answer" has 3 parts. whether it was correct or not, what the question was, and how long the user took to answer. So answer[0] is the first part, a boolean with True for right and False for wrong.

This might make more sense after you get to the point where the project is complete.

Jay Reyes
seal-mask
.a{fill-rule:evenodd;}techdegree
Jay Reyes
Python Web Development Techdegree Student 15,936 Points

Steven, just for self-clarification: the element appended to self.answers contains 2 elements: at [0] we have Correct and at [1] we have datetime.timedelta

Steven Parker
Steven Parker
203,990 Points

Sorry for the delay in responding, but yes, at this point of the project there are just 2 parts, the right/wrong boolean and the time to answer. I was probably thinking of a later expansion that had 3 parts.