Skip to content
Advertisement

Letter Count Dictionary

My homework problem is to write a Python function called LetterCount() which takes a string as an argument and returns a dictionary of letter counts. However, my code includes white space and commas as a part of the dictionary which i don’t want. Can you please help me out. How do i remove the white space from my list? Here is my code?

JavaScript

Advertisement

Answer

You can also check if l is an alphabetic character (if l.isalpha())

Example:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement