Count Vowels Function
Python
Easy
2 views
Problem Description
One line string s is provided. Write function vowel_count(s) and output number of vowels.
Output Format
One integer count.
Official Solution
import sys
s=sys.stdin.read()
if s is None: sys.exit(0)
if s.endswith('\
'):
s=s[:-1]
def vowel_count(t):
v=set('aeiouAEIOU')
c=0
for ch in t:
if ch in v:
c+=1
return c
sys.stdout.write(str(vowel_count(s)))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!