Easy python with dictionary


#1
def add(a,b):
    return a+b
def sub(a,b):
    return b-a
def multiply(a,b):
    return b*a
def divide(a,b):
    return b//a class Solution:
# @param A : list of strings
# @return an integer
    def evalRPN(self, a):
    store={"+":add,"-":sub,"*":multiply,"/":divide}
    stack=[]
    for i in a:
        if i not in store:
            stack.append(int(i))
        else:
            a,b=stack.pop(),stack.pop()
            stack.append(store[i](a,b))
    return stack[0]