Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from string import ascii_uppercase
- strings = input().split()
- total_result = 0
- for sub_string in strings:
- first_letter = sub_string[0]
- last_letter = sub_string[-1]
- number = int(sub_string[1:len(sub_string) - 1])
- first_letter_alphabet_position = ascii_uppercase.index(first_letter.upper()) + 1
- if first_letter.isupper():
- number /= first_letter_alphabet_position
- else:
- number *= first_letter_alphabet_position
- last_letter_alphabet_position = ascii_uppercase.index(last_letter.upper()) + 1
- if last_letter.isupper():
- number -= last_letter_alphabet_position
- else:
- number += last_letter_alphabet_position
- total_result += number
- print(f"{total_result:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement