Use Python Lists as Stacks

>>> stack =[]
>>> stack.append(1)
>>> stack.append(2)
>>> stack.append(2)
>>> stack
[1, 2, 2]
>>> stack.append(3)
>>> stack
[1, 2, 2, 3]
>>> stack.pop()
3
>>> stack.pop()
2
>>> stack
[1, 2]
>>>



Comments

Popular posts from this blog

Basic Git Command for first time github user

Python IMAP list response, listing mailboxes, mailbox status, selecting_mailbox, searching messages, search criteria, fetching messages, whole messages, uploading messages, moving and copying messages, deleting messages, delete mailbox,search with uid