0
String characters
i need help with finding how to find how many characters are in the string for example. input is Hello output to be H,1 e,1 l,2 o,1
1 Answer
0
you will need to create a dictionary, store characters as keys and their amount in string as values
str = 'example string'
stat = dict()
for char in str:
if char in stat:
stat[char] += 1
else
stat[char] = 1
print (stat)