I have an instance that has a dict. how can i modify the dict in a function, by the key from the dict?
class myclass:
def __init__(self):
self.mydict = {'number':0}
def myfunction(foo):
foo.mydict[number] += 10 #<- doesnt work gives me 'global name number not defined'
instance = myclass()
myfunction(instance)
hope you can help me,
thanks!
Actually, this has nothing to do with it being a class attribute:
The key need to be a string.