Skip to content

Commit 95a9957

Browse files
fix: count upper and lower accurate
1 parent ca487a0 commit 95a9957

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

file_handle/File handle text/counter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
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.
913
class 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

0 commit comments

Comments
 (0)