Advertisement
ceiszele

vowels

Dec 14th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. from random import *
  2.  
  3. #function to count the number of vowels of a nominated word
  4. def countvowels(word,counter):
  5. vowels = "aeiou" #list of vowels to compare against the word
  6. for letter in word:
  7. x = 0
  8. for vowel in vowels:
  9. if vowels[x] ==letter: #cycle through the vowels to compare with each letter
  10. counter +=1
  11. break
  12. x += 1
  13. return word, counter #return the number of vowels
  14.  
  15.  
  16. counter = 0
  17. word = input("Enter a word to count the number of vowels: " )
  18. wordcount = countvowels(word, counter)
  19. print("in the word " + wordcount[0] + " there are " + str(wordcount[1])+ " vowels")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement