If this doesnt make sense, let me show you an example.  

Right now, I am trying to evaluate a postfix expression. I have done everything needed, but there is one problem.  

When I have single digits in the expression, everything works fine. This is because during my code, I had to get rid of all spaces.  

For example, the postfix expression `2 1 + 3 *` evaluates to `9`. But when I have the postfix expression `4 13 5 / +` , the evaluated expression is incorrect.  

This is because when I got rid of all the spaces in that expression, the number 13 becomes seperated into two numbers. (1 and 3) I do not want that to happen, but I cannot figure out how to fix this error!  

`Input = 4 13 5 / +`  

`Output = 2`  

The output should be `6`.  

I am using the `.replace(" ", "")` method.  

How do I fix this?
Here is an example of my code.

```
from __future__ import division
import random

formula = input()
formula = formula.replace(" ", "")
OPERATORS = set(['+', '-', '*', '/', '(', ')'])
PRIORITY = {'+':1, '-':1, '*':2, '/':2}

stack = []
prev_op = None
for ch in formula:
  if not ch in OPERATORS:
    stack.append(ch)
  else:
    b = stack.pop()
    a = stack.pop()
    if ch == "+":
      output = int(b)+int(a)
    if ch == "-":
      output = int(b)-int(a)
    if ch == "*":
      output = int(b)*int(a)
    if ch == "/":
      output = int(b)/int(a)

    stack.append(output)

print(output)

```
['https://Stackoverflow.com/questions/66189992', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14923907/']
There are a few issues with your code.

1. Instead of the replace, you can simply use `formula.split()`
2. You are popping the items in the wrong order, you need to pop a before b to get the right answers. You were lucky to have the first case give you the same, but second fails because instead of 13/5 it does 5/13.

I have marked the changes below. Do try it out.

```
from __future__ import division
import random

formula = input().split()                    #<------
OPERATORS = set(['+', '-', '*', '/', '(', ')'])
PRIORITY = {'+':1, '-':1, '*':2, '/':2}

stack = []
prev_op = None
for ch in formula:
    if not ch in OPERATORS:
        stack.append(ch)
    else:
        a = stack.pop()           #<---------
        b = stack.pop()           #<---------
        if ch == "+":
            output = int(b)+int(a)
        if ch == "-":
            output = int(b)-int(a)
        if ch == "*":
            output = int(b)*int(a)
        if ch == "/":
            output = int(b)/int(a)

        stack.append(output)

print(output)

```

```
4 13 5 / +
6

```
Instead of removing spaces, you should keep them: this will make it easy to extract the *words* from the input, using `split`:

```
for ch in formula.split():

```