# Python3 code to demonstrate
# each occurrence frequency using
# naive method
# initializing string
test_str = "GeeksforGeeks"
# using naive method to get count
# of each element in string
all_freq = {}
for i in test_str:
if i in all_freq:
all_freq[i] += 1
else:
all_freq[i] = 1
# printing result
print ("Count of all characters in GeeksforGeeks is :
"
+ str(all_freq))
# Python3 code to demonstrate
# each occurrence frequency using
# dict.get()
# initializing string
test_str = "GeeksforGeeks"
# using dict.get() to get count
# of each element in string
res = {}
for keys in test_str:
res[keys] = res.get(keys, 0) + 1
# printing result
print ("Count of all characters in GeeksforGeeks is :
"
+ str(res))