I need help with a function that will take a string and return a dictionary with how many times each letter is in the string using the count() function
For example, for "0010101", it returns a dictionary saying:
The character frequency of "0010101" is {'0': 4, '1': 3}
def character_frequency(string):
if len(string) == 0:
return "{}"
# insert loop to determine the character counts in the string here
#test code for reference
tests = ["", "0010101", "aaabbb"]
for x in tests:
print('The character frequency of "' + x + '" is', character_frequency(x))