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.
- Prepare
- Python
- Debugging
- Words Score
- Discussions
Words Score
Words Score
Sort by
recency
|
161 Discussions
|
Please Login in order to post a comment
Just the ++score has to be converted into score += 1. Rest of the code stays as it is.
With the use of regex and list comprehension -->
As we all know that vowels are a,e,i,o,u and why it has metioned y in the above one.
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))