Stack Implementation using List

L=[]
L.append(0)
print("push: ",L)
L.append(2)
print("push: ",L)
L.append(4)
print("push: ",L)
L.append(6)
print("push: ",L)
L.append(8)
print("push: ",L)

print("List is: ",L)
print("peek: ",L[-1])
L.pop()
print("pop: ",L)
print("peek: ",L[-1])
L.pop()
print("pop: ",L)
print("peek: ",L[-1])

1 Like

Keep Practicing @dinavahibhavya

1 Like

@dinavahibhavya

Correct, keep it up.
Keep Practicing.