Advertisement
exDotaPro

2019_6_july_6_the_most_powerful_word

Feb 1st, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. VOWELS = 'aAeEiIoOuU'
  2.  
  3. ascii_sum = 0
  4. most_ascii_sum = 0
  5. most_powerful_word = ''
  6.  
  7. command = input()
  8.  
  9. while command != 'End of words':
  10.     word = command
  11.     ascii_sum = 0
  12.  
  13.     for idx in range(len(word)):
  14.         ascii_sum += ord(word[idx])
  15.  
  16.     if word[0] in VOWELS:
  17.         ascii_sum *= len(word)
  18.     else:
  19.         ascii_sum //= len(word)
  20.  
  21.     if ascii_sum > most_ascii_sum:
  22.         most_ascii_sum = ascii_sum
  23.         most_powerful_word = word
  24.  
  25.     command = input()
  26.  
  27. print(f'The most powerful word is {most_powerful_word} - {most_ascii_sum}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement