Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Striped Words by Mahoter
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
text = text.upper()
txt = ""
for l in text:
if l in ',.?!':
txt += ' '
else:
txt += l
res = 0
words = txt.split()
print(words)
for w in words:
if len(w) > 1:
a = 0
b = 0
while a < len(w)-1:
if w[a] in VOWELS and w[a+1] in CONSONANTS or w[a+1] in VOWELS and w[a] in CONSONANTS:
b += 1
a += 1
if a == b:
res += 1
return res
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("My name is ...") == 3, "All words are striped"
assert checkio("Hello world") == 0, "No one"
assert checkio("A quantity of striped words.") == 1, "Only of"
assert checkio("Dog,cat,mouse,bird.Human.") == 3, "Dog, cat and human"
Jan. 17, 2016