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):
vowels = {'a','e','i','o','u','y'}
score = 0
for word in words:
vowels_count = sum(1 for i in word if i in vowels)
if vowels_count%2==0:
score = score+2
else:
score = score+1
return score
if name == "main":
n = int(input())
word = input().split()
words = []
for i in range(n):
if len(word[i])<=20 and word[i].islower():
words.append(word[i])
print(score_words(words))
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 sys
def score_words(words): vowels = {'a','e','i','o','u','y'} score = 0 for word in words: vowels_count = sum(1 for i in word if i in vowels) if vowels_count%2==0: score = score+2 else: score = score+1 return score
if name == "main": n = int(input()) word = input().split() words = [] for i in range(n): if len(word[i])<=20 and word[i].islower(): words.append(word[i]) print(score_words(words))