Advertisement
Antypas

Count vowels in a word

Apr 14th, 2020
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. # Count vowels in a given word (with repetition)
  2.  
  3. english_vowels = ["a", "i", "e", "o", "u"]
  4.  
  5. def vowel_count(word):
  6.     vcount = 0
  7.     for x in word:
  8.         if x in english_vowels:
  9.             vcount += 1
  10.     print("vowel count> ",vcount)
  11.     return vcount
  12.    
  13. word= input("Enter a word > ")    # notice this output is a string, hence iterable
  14. print( "'"+ word +"'"+ " has this many vowels: ",vowel_count(word))
  15.  
  16. # Can also use a list of one-lettered strings (characters?)
  17. print(vowel_count(['a','b','e','s', 'e']))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement