forked from MAZOUZBANK/functional_test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercice2.py
35 lines (30 loc) · 916 Bytes
/
exercice2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class StringAnalyzer:
def __init__(self, input_string):
self.input_string = input_string
def count_vowels(self):
vowels = "aeiou"
count = 0
for char in self.input_string.lower():
if char in vowels:
count += 1
return count
def count_consonants(self):
consonants = "bcdfghjklmnpqrstvwxyz"
count = 0
for char in self.input_string.lower():
if char in consonants:
count += 1
return count
def count_digits(self):
digits = "0123456789"
count = 0
for char in self.input_string:
if char in digits:
count += 1
return count
def count_words(self):
words = self.input_string.split()
return len(words)
def count_lines(self):
lines = self.input_string.split("\n")
return len(lines)