File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
file_handle/File handle text Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 55- Code readability
66"""
77
8+ ## ! Is there any other way than doing it linear?
89
10+
11+ ## ! What will be test cases of it?
12+ # ! Please do let me know.
913class Counter :
1014 def __init__ (self , text : str ) -> None :
1115 self .text = text
12-
1316 # Define the initial count of the lower and upper case.
1417 self .count_lower = 0
1518 self .count_upper = 0
16- self .count ()
19+ self .compute ()
1720
18- def count (self ) -> None :
21+ def compute (self ) -> None :
1922 for char in self .text :
20- if char .lower ():
23+ if char .islower ():
2124 self .count_lower += 1
22- elif char .upper ():
25+ elif char .isupper ():
2326 self .count_upper += 1
24-
25- return (self .count_lower , self .count_upper )
26-
2727 def get_total_lower (self ) -> int :
2828 return self .count_lower
2929
3030 def get_total_upper (self ) -> int :
3131 return self .count_upper
3232
33- def get_total (self ) -> int :
33+ def get_total_chars (self ) -> int :
3434 return self .count_lower + self .count_upper
You can’t perform that action at this time.
0 commit comments