Python: String: Prefix Notation

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


prefix('+ 5 1') -> 6
prefix('- 5 * 6 7') -> 18

Test 1    

Test 2    

Test 3    

Test 4    

Test 5    

Test 6