Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by koyana222
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
NUMBER = "1234567890"
def checkio(text):
converttext = ""
result = 0
text = text.replace("."," ")
text = text.replace(","," ")
text = text.upper()
for i in text:
if i in VOWELS:
converttext += "V"
continue
if i in CONSONANTS:
converttext += "C"
continue
if i in NUMBER:
converttext += "N"
continue
else:
converttext += " "
converttextlist = converttext.split()
for j in converttextlist:
if len(j) != 1:
if "CC" not in j:
if "VV" not in j:
if "N" not in j:
result += 1
return result
#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"
May 16, 2019