f | from fractions import Fraction | f | from fractions import Fraction |
n | inpt = input() | n | s = input() |
| str1 = '' | | new_s = '' |
| str2 = '' | | buf = '' |
| for i in range(len(inpt)): | | for i in range(len(s)): |
| if '0' <= inpt[i] <= '9' or inpt[i] == '.': | | if '0' <= s[i] <= '9' or s[i] == '.': |
| str2 += inpt[i] | | buf += s[i] |
| elif len(str2) != 0: | | elif len(buf) != 0: |
| str1 += "Fraction('" + str2 + "')" + inpt[i] | | new_s += "Fraction('" + buf + "')" + s[i] |
| str2 = '' | | buf = '' |
| else: | | else: |
t | str1 += inpt[i] | t | new_s += s[i] |
| if i == len(inpt) - 1 and len(str2) != 0: | | if i == len(s) - 1 and len(buf) != 0: |
| str1 += "Fraction('" + str2 + "')" | | new_s += "Fraction('" + buf + "')" |
| print(eval(str1)) | | print(eval(new_s)) |