Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Striped Words by hamatimaguro
VOWELS = "AEIOUY"
CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ"
def checkio(text):
texts=text.replace('.',' ').replace(','," ").replace('?'," ").split(' ')
texts=[x for x in texts if len(x)>=2]
temp=''
answers=[]
number=0
for word in texts:
for letters in word:
if letters.upper() in VOWELS:
temp+='0'
elif letters.upper() in CONSONANTS:
temp+='1'
else:
temp+='00'
answers.append(temp)
temp=''
for check in answers:
if "00" not in check and "11" not in check:
number+=1
return(number)
return 0
#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("To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it?")==8
Jan. 27, 2020
Comments: