Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by Ambulanss
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def onlywords(string):
result = ""
for word in string.split():
for letter in word:
if letter.isalpha() or letter.isdigit():
result = result + letter
else:
result = result + " "
result = result + " "
return result.upper()
def checkio(text):
count = 0
text = onlywords(text)
print(text)
condition = True
for word in text.split():
if not word.isalpha():
condition = False
if len(word) == 1:
condition = False
for i in range(len(word)-1):
if (word[i] in VOWELS and word[i+1] in VOWELS) or (word[i] in CONSONANTS and word[i+1] in CONSONANTS) or (word[i].isalpha()==0 or word[i+1].isalpha()==0):
condition = False
break
if condition == True:
count+=1
print(word)
condition = True
return count
#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"
assert checkio("1st 2a ab3er root rate") == 1
Nov. 2, 2016