Write a python function that takes a string as an argument and searches all
the characters having at least three occurrences (except the spaces and
special characters) in that string. Then, prepare and RETURN a dictionary
where the keys will be the characters and values will be summation of the
positions of those characters in the string. (You are not allowed to use
builtin .count() function here)
str = input("Enter the string: ")
# using naive method to get count
# of each element in string
all_freq = {}
for i in str:
if i in all_freq:
all_freq[i] += 1
else:
all_freq[i] = 1
# printing result
print ("Count of all characters in the given is :\n "
+ str(all_freq))
Comments
Leave a comment