Advertisement
ganiyuisholaafeez

Count Method

Feb 19th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. """ This is a function that returns the count of
  2. vowel characters in a string"""
  3.  
  4. # The function is named vowel_count and it accepts a single argument
  5. def vowel_count(string):
  6.  
  7. # Converting string argument to lower case
  8.     lowercase = string.lower()
  9.  
  10. # Searching and Counting the vowel characters in the lowercase version of the string
  11. # The \ sign is merely for continuation
  12.     counter = lowercase.count("a") + lowercase.count("e") + lowercase.count("i")\
  13.         + lowercase.count("o") + lowercase.count("u")
  14.  
  15. # Returning the count after the traversing
  16.     return counter
  17.  
  18. # Function Invocation
  19. print(vowel_count("Estate"))
  20. print(vowel_count("helicopter"))
  21. print(vowel_count("ssh"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement