Advertisement
Spocoman

06. Vowels Sum

Dec 23rd, 2021 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. text = input()
  2. sum = 0
  3.  
  4. for char in text:
  5.     if char == 'a':
  6.         sum += 1
  7.     elif char == 'e':
  8.         sum += 2
  9.     elif char == 'i':
  10.         sum += 3
  11.     elif char == 'o':
  12.         sum += 4
  13.     elif char == 'u':
  14.         sum += 5
  15.  
  16. print(sum)
  17.  
  18. ИЛИ:
  19.  
  20. vowels = 'aeiou'
  21. text = input()
  22. sum = 0
  23.  
  24. for char in text:
  25.     if char in vowels:
  26.         sum += vowels.index(char) + 1
  27.  
  28. print(sum)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement