Answer to Question #281825 in Python for Munif

Question #281825

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)


1
Expert's answer
2021-12-22T01:10:06-0500
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))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS