0

The following code

def test(dict_obj={}):
    for k, v in dict_obj.items():
        print(k, v)
    dict_obj['test'] = 2

test()
test()

gives output

test 2

So python does not create a new dictionary in the second call, but points to the same object? Why is this?

blanNL
  • 113
  • 7

0 Answers0