Sichanov

02. Character Multiplier

Nov 12th, 2021
1,047
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. two_strings = input().split()
  2. longest = max(two_strings, key=len)
  3. two_strings.remove(longest)
  4. shortest = two_strings[0]
  5. sum_of_chars = 0
  6. for i in range(len(longest)):
  7.     if i < len(shortest):
  8.         sum_of_chars += ord(longest[i]) * ord(shortest[i])
  9.     else:
  10.         sum_of_chars += ord(longest[i])
  11. print(sum_of_chars)
Advertisement
Add Comment
Please, Sign In to add comment