Eldin Guzin2,595 Points
I have a question about one part of this video
def total_correct(self): # return the total # of correct answers total = 0 for answer in self.answers: if answer: total += 1 return total
how does this exactly work, this is extremely confusing, what is self.answers exactly, if answer , doesn't that always check the first answer, doesn't really make sense to me. An explanation would be very helpful here.
Steven Parker207,598 Points
"answers" (plural) is the whole list, but "answer" (singular) is a tuple where the first part is a boolean indicating whether it was correct or not. So "answer" is that boolean value.
That means this loop is going through the list and counting up all the correct answers.