I have recently started learning python and I am trying to define a function called count_text
however I am struggling a lot.
I am aiming to create a function that determines how many letters(lower or uppercase), numbers, spaces or other characters(i.e. #@^
) are found in text. The function is supposed to return the four totals in a dictionary with keys of "letters"
, "numbers"
, "spaces"
and "others"
.
E.g. count_text('Hello123')
should return:
{'letters': 3, 'numbers': 3, 'spaces': 0, 'others': 0}
Any help would be greatly appreciated.