We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def score_words(words):
pattern = re.compile(r'[aeiouy]')
sum1=0
for i in words.split():
if len(pattern.findall(i))%2==0:
sum1 +=2
else:
sum1 +=1
return(sum1)
if name == "main":
n = int(input())
word = input()
print(score_words(word))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Words Score
You are viewing a single comment's thread. Return to all comments →
import re
def score_words(words): pattern = re.compile(r'[aeiouy]') sum1=0 for i in words.split(): if len(pattern.findall(i))%2==0: sum1 +=2 else: sum1 +=1 return(sum1) if name == "main": n = int(input()) word = input() print(score_words(word))