Reverse polish notation
Reverse polish notation is a postfix notation for calculations. Instead of writing 1 + 2 we would write 1 2 +. Why? Well RPN does not need brackets to begin with! You can find more information about RPN by following the link below.
http://www.calculator.org/rpn.aspx (information about reverse polish)
Your task is to read in a string from the command line (using raw_input) and calcualte the answer. You should –
- Use a stack to help you (http://docs.python.org/tutorial/datastructures.html see the section on stacks)
- If there are less than 2 items on the stack and a operator is seen (e.g. +) then return an error
- Output the answer once the input has been fully parsed.
You should treat a space as the seperator. You may wish to look at the split() string function (http://docs.python.org/library/string.html#string.split)

You need to log in or create an account to submit code!











