A Company has launched a new test editor that allows users to enter English letters numbers, and whitespaces only. If as 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 if misses by a given user in the given input.
Input:
The input consist of a string textInput representing the text that
us entered in the text editor by the user in the given input
Output
Print an integer representing the number of misses by a given user
in the given input.
Example:
Aa a234bc@ sad$ hsagd^
Output:
3
Explanation:
The characters that are counted as misses by the editor ar [‘@’,’$’,’^’]
Code(Python):
def
editorMiss(text):
count=0
for ch
in text:
if((ch
>= 'a' and
ch <= 'z')
or (ch >= 'A'
and ch <= 'Z')):
pass
elif(ch
>= '0' and
ch <= '9'):
pass
else:
if(ch=="
"):
pass
else:
count=count+1
0 Comments
Post a Comment