Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHenry Lin
11,636 PointsI 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
231,248 PointsThe "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
Python Web Development Techdegree Student 15,937 PointsJay Reyes
Python Web Development Techdegree Student 15,937 PointsSteven, just for self-clarification: the element appended to self.answers contains 2 elements: at [0] we have
Correct
and at [1] we havedatetime.timedelta
Steven Parker
231,248 PointsSteven Parker
231,248 PointsSorry 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.