I have to implement a class called Marathon
. In the creator a have to declare a dictionary with key 'runner' and value 'time'. I declare the dictionary in the creator. Then when I try to use that dictionary in the register method an error appear NameError: name 'my_marathon' is not defined
. Can someone tell me how I access to that dictionary from my register method?
class Marathon:
def __init__(self):
"""Set up this marathon without any runners."""
my_marathon = {'runner', 'time'}
def register(self, runner):
"""Register the runner. Return nothing."""
my_marathon['runner'] = runner