Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by SzOp
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
sum = 0
text = text.replace(".", " ").replace(",", " ").replace("?", " ").upper().split()
for word in text:
flag = True
for i in range(len(word)-1):
if ((word[i] in VOWELS) and (word[i+1] in CONSONANTS)) or ((word[i] in CONSONANTS) and (word[i+1] in VOWELS)):
flag=flag
else:
flag = False
if flag and len(word)-1>0:
sum+=1
return sum
#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"
Nov. 1, 2018