22 lines
503 B
Python
22 lines
503 B
Python
'''
|
|
Given a string as a+b expression, where a and b are integers, return a sum of a and b as an integer.
|
|
|
|
Example 1
|
|
Input:
|
|
4+2
|
|
Output:
|
|
6
|
|
'''
|
|
class Solution(object):
|
|
def solve(self, expression:str) -> int:
|
|
print(f"expression: {expression}")
|
|
left, right = expression.split('+')
|
|
int_left = int(left)
|
|
int_right = int(right)
|
|
sum = int_left + int_right
|
|
return sum
|
|
|
|
s = Solution()
|
|
print(s.solve("4+2")) # Output: 6
|
|
print(s.solve("10+20")) # Output: 30
|