this calculate function should work calculate((1, 2, '+', 3, '*')) return 9 1. take 1, push 1 # stack [1] 2. take 2, push 2 #stack [1, 2] 3. take '+', pop 2, pop 1, calculate 1+2 = 3, push 3 #stack [3] 4. take 3, push 3 #stack [3, 3] 5. take '*', pop 3, pop 3, calculate 3 * 3 = 9, push 9 #stack [9] 6. input empty, pop 9, return 9 i don't know how use string '+' here add 1 , 2 together. seems impossible. here code. suppose convert tuple , put list pop first 2 number out combine binary operators '+', '-', '*', '/' def calculate(inputs): #(1, 2, '+', 3, '/') if len(inputs) <= 1: return inputs[0] in range(len(inputs)+1): ## (0,...5) s = make_empty_stack() # [] first = push_stack(s, inputs[i]) #[1] # push_stack pushes item onto stack s, returns stack second = push_stack(s, inputs[i + 1]) ##[2,1] third = push_stack(s, inputs[i +2]