# Python - Reverse Polish Notation [duplicate]

Possible Duplicate:
Reverse Polish notation

Create a function named rpn in python to evaluate a string written in Reverse Polish notation

Numbers must be separated by one or more spaces; operators do not need to be separated by spaces. Must support +, -, * and /.

Return can be any type that int() will accept

Eval is allowed.

Examples:

>>> 3 7 +
10

>>> 1 2+3*4-
5


## marked as duplicate by hallvabo, J B, Peter Taylor, Gareth, gnibblerDec 21 '11 at 9:46

• Should a different character (such as _) be used to represent negative numbers? In your current specification, does 2 3 -7 * mean 2 * 3 * -7 or (2 - 3) * 7? – Dillon Cower Dec 20 '11 at 21:28