Answer to Question #326282 in Python for Michael

Question #326282

Write a python program to count number of each characters in a string


For example python


P=1,y=1,t=1,h=1,o=1,n=1

1
Expert's answer
2022-04-09T17:53:14-0400
inputString=input("Enter a string: ")
freq = {}
  
for i in inputString:
    if i in freq:
        freq[i] += 1
    else:
        freq[i] = 1
  
print (str(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