CJCoding With Joseph
15free / daySign inCreate account

Digits Versus Letters

Read one line of text and sort its characters into three groups: digits, letters and everything else (spaces, punctuation). Walk the line with a for loop and, for each character, test character.isdigit() first, then character.isalpha() in an elif, and count the rest in the else branch; both methods return True or False. Print three lines in this order and form: Digits: <n>, Letters: <n> and Others: <n>. Input: one line, no prompt; the line may contain spaces.

Expected Output:

Digits: 3
Letters: 3
Others: 2

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Strings
📥 Auto-Input:
abc123!?\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.