コード例 #1
0
def evaluate(row):
    stack = Stack()
    total = 0

    for i in range(len(row)):
        if i in ("*", "+", "-"):
            one = stack.pop()
            two = stack.pop()
            total += operator(sign, one, two)
            stack.push(total)
        else:
            stack.push(row[i])

    return stack.string()