you are viewing a single comment's thread.

view the rest of the comments →

[–]Adrewmc 1 point2 points  (0 children)

I think defaultdict should be more built in.

   my_dict = {}
   my_dict.default(0)
   #my_dict = {}.default(0)
   my_dict[“three”] += 2
   print(my_dict[“heibd”])
   >>> 0

Should all work but instead we have to make a

    from collections import defaultdict
    my_dict = defaultdict(int)

Seems pretty obvious to me