Advertisement
brendan-stanford

vowel_count

Aug 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. from random import randint
  2.  
  3. #takes the score list and a vowel list to check from and returns the number of vowels (mark)
  4. def mark_count(score_list, vowel_list):
  5. mark = 0
  6. for score in score_list:
  7. for letter in vowel_list:
  8. if score == letter:
  9. mark += 1
  10. return mark
  11.  
  12. #scores will store random letters, alphabet is the source of all possible letters, and vowels is the list to reference from
  13. scores = []
  14. vowels = "aeiou"
  15. alphabet = "abcdefghijklmnopqrstuvwxyz"
  16.  
  17. #randomly generate vowels by using an integer from 0-25 as an index for the alphabet list
  18. for x in range(0, 30):
  19. chance = randint(0, 25)
  20. scores.append(alphabet[chance])
  21.  
  22. #finish program by printing random list and calling mark_count function
  23. print(scores)
  24.  
  25. grades = mark_count(scores, vowels)
  26.  
  27. print("{0} learners got input mark".format(grades))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement