Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by michal_bien
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkword(word):
isVowel=None
for char in word:
if isVowel==None:
if char in VOWELS.lower(): isVowel=True
elif char in CONSONANTS.lower(): isVowel=False
elif isVowel and char in VOWELS.lower(): return False
elif not isVowel and char in CONSONANTS.lower(): return False
else: isVowel=(not isVowel)
return True
def checkio(text):
text=text.lower().replace('.',' ').replace(',',' ').replace('?','').split()
print(text)
res=0
for word in text:
if len(word)<=1 or not word.isalpha(): continue
if checkword(word): res+=1
return res
Oct. 14, 2016