//in C++
unordered_map<int,int>m;
for (i = 0; i < n; ++i) {
m[arr[i]]++;
}
#in python
my_dict = {}
for i in range(len(arr)):
my_dict[arr[i]] += 1 #This gives key error
I am sure that the default value is set to zero in C++, so it works. How to go about it in Python?