5. Write a function in Python PUSH() to insert an element in the stack. After inserting the element display
the stack
Answers
Answered by
11
def PUSH(item, stack):
stack += [item]
return stack
stack = []
for item in ["onions", "carrots", "peppers"]:
print(PUSH(item, stack))
Similar questions