Character Types
Completed
Read a line and print how many letters, digits and spaces it contains, as letters=L digits=D spaces=S.
Input
One line.
Output
One line in the format shown.
Example
Input
Hello World 2026
Output
letters=10 digits=4 spaces=2
Editor
Python
Hints
Loop over the string one character at a time.
Use ch.isalpha() and ch.isdigit().
Solution explanation
Strings are iterable. isalpha, isdigit, isspace, isupper and friends classify characters.
Show solution
s = input()
letters = digits = spaces = 0
for ch in s:
if ch.isalpha():
letters += 1
elif ch.isdigit():
digits += 1
elif ch == " ":
spaces += 1
print(f"letters={letters} digits={digits} spaces={spaces}")