Advertisement
ifigazsi

Vowel count

Jan 19th, 2024 (edited)
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #### A ####
  2.  
  3. sentence = "Hello World."
  4. vowels = {"a", "e", "i", "o", "u"}
  5. stat = {}
  6. for c in sentence.lower():
  7.     if c in vowels:
  8.         stat[c] = stat.get(c, 0) + 1
  9. print(stat)
  10.  
  11. #### B ####
  12. sentence = "Hello World."
  13. vowels = {"a", "e", "i", "o", "u"}
  14. for v in vowels:
  15.     print(f"{v}: {sentence.lower().count(v)}")
  16.  
  17. #### C ####
  18. sentence = "Hello World."
  19. print([(x, sentence.lower().count(x)) for x in {"a", "e", "i", "o", "u"}])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement