MCPcopy Create free account
hub / github.com/geekcomputers/Python / Counter

Class Counter

file_handle/File handle text/counter.py:22–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20# does it count only alphabets or numerics too?
21# ? what about other characters?
22class Counter:
23 def __init__(self, text: str) -> None:
24 self.text = text
25 # Define the initial count of the lower and upper case.
26 self.count_lower = 0
27 self.count_upper = 0
28 self.compute()
29
30 def compute(self) -> None:
31 for char in self.text:
32 if char.islower():
33 self.count_lower += 1
34 elif char.isupper():
35 self.count_upper += 1
36
37 def get_total_lower(self) -> int:
38 return self.count_lower
39
40 def get_total_upper(self) -> int:
41 return self.count_upper
42
43 def get_total_chars(self) -> int:
44 return self.count_lower + self.count_upper

Callers 2

lowercaseFunction · 0.90
lowercaseFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected