Input Format
The input is read by the provided locked code template. In the first line, there is a single integer  denoting the number of words. In the second line, there are  space-separated lowercase words.
Constraints
  • Each word has at most  letters and all letters are English lowercase letters
Output Format
The output is produced by the provided and locked code template. It calls function score_words with the list of words read from the input as the argument and prints the returned score to the output.

hackerrank words score problem solution in python programming

Problem solution in Python 3 programming language.

def is_vowel(letter):
    return letter in ['a''e''i''o''u''y']
import re
from functools import reduce
def score_words(words): 
    return reduce(lambda x, y: x+y, 
[2 if (len(re.findall('[aeiouy]',a))%2 == 0else 1 for a in words], 0)
n = int(input())
words = input().split()
print(score_words(words))

Problem solution in Python 2 programming language.

def is_vowel(letter):
    return letter in ['a''e''i''o''u''y']
import re
from functools import reduce
def score_words(words): 
    return reduce(lambda x, y: x+y, 
[2 if (len(re.findall('[aeiouy]',a))%2 == 0else 1 for a in words], 0)
n = int(raw_input())
words = raw_input().split()
print score_words(words)