Advertisement
rickzman

Untitled

Dec 12th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. # count vowels in word
  2.  
  3. from random import randint
  4.  
  5. def count(vowels, word):
  6. vowel = [0, 0, 0, 0, 0]
  7. for letter in word:
  8. if letter == vowels[0]:
  9. vowel[0] += 1
  10. elif letter == vowels[1]:
  11. vowel[1] += 1
  12. elif letter == vowels[2]:
  13. vowel[2] += 1
  14. elif letter == vowels[3]:
  15. vowel[3] += 1
  16. elif letter == vowels[4]:
  17. vowel[4] += 1
  18. return vowel
  19.  
  20. word = "occurrences"
  21. vowels = "aeiou"
  22.  
  23. number_vowels = count(vowels, word)
  24.  
  25. print("The word "+ word+ " contains")
  26. for i in range(5):
  27. x = i -1
  28. print(number_vowels[x], vowels[x])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement