Hi there,
Can anyone help. I’ve been battling with the .attendance bonus challenge in the classes section of the python path. Where we add a student’s attendance to a dictionary of dates and booleans.
I keep getting the error: “TypeError: ‘dict’ object is not callable” It’s fine the first time it’s used but whenever I try to add a second entry into the dictionary I get the error message. Here’s my code below.
The question is:
“Add an instance variable to Student that is a dictionary called .attendance , with dates as keys and booleans as values that indicate whether the student attended school that day.”
The instance variable should be defined in the __init__() method.
As for how it is updated that will take another method.
Eg.
# before the class
from datetime import datetime
# in the class
def set_attendance(self, value):
now = datetime.now()
self['{}/{}/{}'.format(now.year, now.month, now.day)] = value