Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by janusztracz73ms
VOWELS = "AEIOUYaeiouy"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz"
def checkio(text):
count = 0
bolo = text.replace(".", " ").replace(",", " ").replace(";", " ").replace("?", " ")
lolo = bolo.split(" ")
print(lolo)
for word in lolo:
x = 0
for letter in range(len(word) - 1):
print(word[letter])
if word[letter] in VOWELS:
if word[letter + 1] in CONSONANTS:
x += 1
elif word[letter] in CONSONANTS:
if word[letter + 1] in VOWELS:
x += 1
if len(word) != 1:
if x == (len(word) - 1):
count += 1
print(count)
return count
#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"
Oct. 21, 2016