Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import floor
- check_first_letter = False
- max_sum_ascii = 0
- sum_ascii_word = 0
- while True:
- word = input()
- if word == 'End of words':
- break
- for current_word in word:
- sum_ascii_word += ord(current_word)
- if word[0] == 'a' or word[0] == 'A' or word[0] == 'e' or word[0] == 'E' or word[0] == 'i' or word[0] == 'I'\
- or word[0] == 'o' or word[0] == 'O' or word[0] == 'u' or word[0] == 'U' or word[0] == 'y' or word[0] == 'Y':
- check_first_letter = True
- sum_ascii_word = sum_ascii_word * len(word)
- else:
- check_first_letter = False
- sum_ascii_word = floor(sum_ascii_word / len(word))
- if sum_ascii_word > max_sum_ascii:
- max_sum_ascii = sum_ascii_word
- max_word = word
- sum_ascii_word = 0
- print(f"The most powerful word is {max_word} - {max_sum_ascii}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement