Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by mehWincenty
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def isvowel(a):
for i in VOWELS :
if i == a :
return True
return False
def checkio(text):
text = text.replace(".", " ")
text = text.replace(",", " ")
text = text.replace("?", " ")
text = text.replace("!", " ")
words = text.split(" ")
while '' in words: words.remove('')
ret = 0
for i in words :
vo = not isvowel(i[0].upper())
strp = True
if len(i) == 1:
continue
for j in i :
if not j.isalpha() :
strp = False
break
vo = not vo
if isvowel(j.upper()) == vo :
continue
else :
strp = False
break
if strp :
ret += 1
return ret
#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. 11, 2016