Program - Given an input string, count occurrences of all characters within a string


Topic: Program - Given an input string, count occurrences of all characters within a string

Solution

str1 = "Apple"
countDict = dict()
for char in str1:
  count = str1.count(char)
  countDict[char]=count
print(countDict)



List all Python Programs