Skip to content

Tag: stack

pushing and poping into new list

I am trying to make a loop that if the program sees a letter or number it will push(x) into a new list and if it sees an asterisk * it must pop(). It is more of a stack algorithm where the first letter or number in is the last one out. FILO First in last out For example If

Python prefix to infix notation using a stack data structure

I have an assignment problem on using a stack data structure to solve problems. I am prompted to make the following stack function. Task: Using the stack you created, write the function prefix_infix that takes in a prefix expression (represented as a list) and returns the expression in fully parenthesized inf…