Python infix to postfix conversion

In Python, I’ve begun to solve Data Structure difficulties. I’m converting from infix to postfix, however I’m having trouble debugging a mistake in my software. The last return statement, when I do the join operation, contains NONE input.

When I started debugging, I saw that something is incorrect in this section of code following the first push operation (for *). After that, whenever I call pop(), it returns NONE instead of *. Could someone please point out what is wrong here?

        while (not s.isEmpty()) and (prec[s.peek()] >= prec[token]):
            #print token
            #print outlst
        print (s.peek())*

Source: Scaler, Wiki

Hi, I am happy to help if I can.

Sorry, but I am having a hard time following your question. You mention a “first push operation (for *)”, but I don’t see a for statement in your example code. Also, your example code has *else and print()*, and I don’t understand what * is supposed to mean in those places.

Can you perhaps come up with a minimal but runnable code sample which demonstrates the problem? And show us the input you give that code, what the code gives in response to that input, and your expected output?