Relative Content

Tag Archive for pythondictionary

Append to dictionary

In the code below, I’m trying to append to a dictionary, I’m still relatively new to Python and couldn’t find a way to do this, after a lot of research.

In Python, what does dict.pop(a,b) mean?

class a(object): data={‘a’:’aaa’,’b’:’bbb’,’c’:’ccc’} def pop(self, key, *args): return self.data.pop(key, *args)#what is this mean. b=a() print b.pop(‘a’,{‘b’:’bbb’}) print b.data self.data.pop(key, *args) ←—— why is there a second argument? python dictionary 1 The pop method of dicts (like self.data, i.e. {‘a’:’aaa’,’b’:’bbb’,’c’:’ccc’}, here) takes two arguments — see the docs The second argument, default, is what pop returns […]