Advertisement
ALEXANDAR_GEORGIEV

the_most_powerful_word_2

Jun 15th, 2022
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. from math import floor
  2. check_first_letter = False
  3. max_sum_ascii = 0
  4. sum_ascii_word = 0
  5. while True:
  6.     word = input()
  7.     if word == 'End of words':
  8.         break
  9.     for current_word in word:
  10.         sum_ascii_word += ord(current_word)
  11.     if word[0] == 'a' or word[0] == 'A' or word[0] == 'e' or word[0] == 'E' or word[0] == 'i' or word[0] == 'I'\
  12.             or word[0] == 'o' or word[0] == 'O' or word[0] == 'u' or word[0] == 'U' or word[0] == 'y' or word[0] == 'Y':
  13.         check_first_letter = True
  14.         sum_ascii_word = sum_ascii_word * len(word)
  15.     else:
  16.         check_first_letter = False
  17.         sum_ascii_word = floor(sum_ascii_word / len(word))
  18.  
  19.     if sum_ascii_word > max_sum_ascii:
  20.         max_sum_ascii = sum_ascii_word
  21.         max_word = word
  22.     sum_ascii_word = 0
  23.  
  24. print(f"The most powerful word is {max_word} - {max_sum_ascii}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement