Computer Science

Write a function Push() which takes number as argument and add in a stack "MyValue".

Python

Python Stack

2 Likes

Answer

MyValue = []

def Push(number):
    MyValue.append(number)
    print(number, "pushed to the stack.")

Push(5)
Push(10)
Push(15)

Output

5 pushed to the stack.
10 pushed to the stack.
15 pushed to the stack.

Answered By

2 Likes


Related Questions