Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by Bartosz_M
VOWELS = "AEIOUYaeiouy"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz"
def checkio(text):
counter = 0
text = text.replace(",", " ").replace(".", " ").replace(";", " ").replace("?", " ")
text = text.split(" ")
for word in text:
pomoc = 0
for letter in range(len(word) - 1):
if word[letter] in VOWELS and word[letter + 1] in CONSONANTS:
pomoc += 1
elif word[letter] in CONSONANTS and word[letter + 1] in VOWELS:
pomoc += 1
if len(word) != 1:
if pomoc == (len(word) - 1):
counter += 1
return counter
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("For science, music, sport, etc, Europe uses the same vocabulary. The languages only differ in their grammar, their pronunciation and their most common words.") == 6, "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"
Nov. 22, 2016