Count Digits Letters Others
Python
Medium
3 views
Problem Description
A string s is provided (may contain spaces). Count how many characters are digits, how many are English letters, and how many are others. Output three counts.
Input Format
One line string s.
Output Format
One line: digits letters others.
Official Solution
import sys
s=sys.stdin.read()
if s is None: sys.exit(0)
if s.endswith('\
'):
s=s[:-1]
d=0
l=0
o=0
for ch in s:
if '0'<=ch<='9':
d+=1
elif ('A'<=ch<='Z') or ('a'<=ch<='z'):
l+=1
else:
o+=1
sys.stdout.write(f'{d} {l} {o}')
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!