-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstripped.py
More file actions
40 lines (35 loc) · 1.06 KB
/
stripped.py
File metadata and controls
40 lines (35 loc) · 1.06 KB
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
36
37
38
39
40
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def split_text(text):
result = []
temp_text = ''
for i in text:
if i.isalpha() or i.isdigit():
temp_text += i.upper()
else:
result.append(temp_text)
temp_text = ''
if temp_text:
result.append(temp_text)
print([i for i in result if i])
return [i for i in result if i]
def checkio(text):
counter = 0
for j in split_text(text):
not_striped = True
if len(j) == 1:
not_striped = False
# print(zip(j, j[1:]))
for i in zip(j, j[1:]):
if ((i[0] in VOWELS + CONSONANTS)
and (i[1] in VOWELS + CONSONANTS)):
if ((i[0] in CONSONANTS and i[1] in CONSONANTS)
or (i[1] in VOWELS and i[0] in VOWELS)):
not_striped = False
break
else:
not_striped = False
if not_striped:
counter += 1
return counter
print(checkio("My name is ...")) # == 3