I declared an empty dictionary at the front of the class. Why does the function suddenly have a value in it?

do questions on a platform similar to leetcode, youdao connectivity search.

clipboard.png

The

function is placed in the class
instead of using def _ _ init__ at the beginning of the class, an empty dictionary is declared directly

but when you run the problem-solving function later, when you basically do nothing at first,
print to see why there is value in this empty dictionary.

(the outer main function only calls the accountsMerge function)

what"s going on?

and this code point test passed, the dictionary behind the test is still empty, but as soon as it is submitted, it will become a situation in which the dictionary suddenly has a value.

later, puzzled, I created a new def _ _ init__ initialization function, and put father= {} into it before passing

.

what on earth is going on? Why does it suddenly have value, or does it just have a system bug?

Jun.16,2022

you can use leetcode to do exercises
when he verifies, it's like this.

a = Solution() -sharp a
a.accountMerge(xxx) == xxxx -sharp 
a.accountMerge(xxx1) == xxxx2 -sharp afatherfather
accountMergeself.father = {} 
Menu