Count Specific Characters
EasyPractice library · +10 XPstringscountingloops
Given a string S, count the number of occurrences of the character 'a' and the character 'z' in S. Print these two counts separated by a space.
Input
A single line containing the string S. S consists of lowercase English letters.
Output
A single line with two integers separated by a space: the count of 'a's and the count of 'z's in S.
Constraints
The length of S is between 1 and 1000, inclusive.
Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests
Example 1
Input
abracadabra
Output
5 0
Counts 5 'a's and 0 'z's.
Example 2
Input
zebra
Output
1 1
Counts 1 'a' and 1 'z'.
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
abracadabra
Example 2 input
zebra