Count Non-Alphabetic Characters
EasyPractice library · +10 XPstringscountingloops
Given a string S, consisting of uppercase letters, lowercase letters, digits, and symbols, count the number of characters in S that are NOT English alphabet letters (a-z, A-Z).
Input
A single line containing the string S.
Output
A single integer representing the count of non-alphabetic characters.
Constraints
The length of S is between 1 and 1000, inclusive.
Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests
Example 1
Input
Hello World! 123
Output
6
The non-alphabetic characters are ' ', '!', ' ', '1', '2', '3'. The count is 6.
Example 2
Input
UPPERlowerCASE
Output
0
All characters are letters. The count is 0.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
Hello World! 123
Example 2 input
UPPERlowerCASE