A company has launched a new text editor that allows users to enter English letters, numbers and whitespaces only. If a user attempts to enter any other type of character, it is counted as a miss. Given a string of text, write an algorithm to help the developer detect the number of misses by a given user in the given input.
Input
The input consists of a string textlnput, representing the text that is entered in the text editor by the user.
Output
Print an integer representing the number of misses by a given user in the given input.
Constraints
NA
Example
Input:
aa a234bc@ sad$ hsagd^
Output:
3
Explanation:
The characters that are counted as misses by the editor are [‘@’,’$’,’^’].
Solution: In Python
x = input()
count = 0
for i in x:
if i.isalnum() or (i==" "):
pass
else:
count+=1
print(count)
Also Checkout