Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
issubset() solution in Clear category for Striped Words by vnkvstnk
VOWELS = set("AEIOUY")
CONSONANTS = set("BCDFGHJKLMNPQRSTVWXZ")
import re
def checkio(text):
text = [x.upper() for x in re.split(r"[ ,.!?:;]", text) if len(x) > 1]
counter = 0
for word in text:
odd, even = set(word[::2]), set(word[1::2])
condition_1 = odd.issubset(VOWELS) and even.issubset(CONSONANTS)
condition_2 = odd.issubset(CONSONANTS) and even.issubset(VOWELS)
if condition_1 or condition_2:
counter += 1
return counter
June 2, 2019
Comments: