Advertisement
DiYane

Character multiplier

Sep 26th, 2023
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. def characters_multiply(first_string, second_string):
  2.     first_string = [ord(num) for num in first_string]
  3.     second_string = [ord(num) for num in second_string]
  4.     first_string_len = len(first_string)
  5.     second_string_len = len(second_string)
  6.     if first_string_len > second_string_len:
  7.         for index in range(first_string_len - second_string_len):
  8.             second_string.append(1)
  9.     elif first_string_len < second_string_len:
  10.         for index in range(second_string_len - first_string_len):
  11.             first_string.append(1)
  12.     print(sum([first_string[index] * second_string[index] for index in range(len(first_string))]))
  13.  
  14. string_one, string_two = input().split()
  15. characters_multiply(string_one, string_two)
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement