Python: String: Postfix Notation

Write the function postfix that takes a string containing a postfix expression and returns the result of the expression as a number. More information about postfix expression can be found here. Possible operations are +-*/^ where ^ represents power.


postfix('5 1 +') -> 6
postfix('4 2 + 3 5 1 -  * +') -> 18

Test 1    

Test 2    

Test 3    

Test 4    

Test 5    

Test 6