File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Problem Link: https://practice.geeksforgeeks.org/problems/count-alphabets/0
3
+
4
+ Given a string, print the number of alphabets present in the string.
5
+
6
+ Input:
7
+ The first line of input contains an integer T denoting the number of test cases.
8
+ The description of T test cases follows.Each test case contains a single string.
9
+
10
+ Output:
11
+ Print the number of alphabets present in the string.
12
+
13
+ Constraints:
14
+ 1<=T<=30
15
+ 1<=size of string <=100
16
+
17
+ Example:
18
+ Input:
19
+ 2
20
+ adjfjh23
21
+ njnfn_+-jf
22
+
23
+ Output:
24
+ 6
25
+ 7
26
+ """
27
+ def count_alphabets (s ):
28
+ count = 0
29
+ for c in s :
30
+ if c .isalpha ():
31
+ count += 1
32
+ return count
33
+
34
+ for _ in range (int (input ())):
35
+ s = input ()
36
+ print (count_alphabets (s ))
You can’t perform that action at this time.
0 commit comments