[Solved] Counting the Frequency of Letters in a string (Python) [closed]


You could just check the input with if else and raise an Error if needed with a custom message

if original_input == "":
    raise RuntimeError("Empty input")
else:
    # Your code goes there

As a side not, input() is enough, no need to add quotes ""

Edit: This question was edited, the original question was to check if an input is empty.

Second edit:

If you want your code to print letters as in your output, you should iterate over your word instead over your alphabet:

for c in word:
     print("The letter", c ,"occured", word.count(c), "times")

1

solved Counting the Frequency of Letters in a string (Python) [closed]