Skip to content

Instantly share code, notes, and snippets.

@luizomf
Created April 4, 2020 07:36
Show Gist options
  • Select an option

  • Save luizomf/433e300cf984cff1dd716b61f3f5b24f to your computer and use it in GitHub Desktop.

Select an option

Save luizomf/433e300cf984cff1dd716b61f3f5b24f to your computer and use it in GitHub Desktop.
# Para Type annotation
from typing import List
# Pilha de livros com type annotation
stack_of_books: List[str] = [] # {1}
# Adicionando livros no topo da pilha
stack_of_books.append('Livro 1') # {2}
stack_of_books.append('Livro 2') # {2}
stack_of_books.append('Livro 3') # {2}
# Obtendo o elemento mais novo
book_1 = stack_of_books.pop() # Livro 3 {3}
book_2 = stack_of_books.pop() # Livro 2 {3}
book_3 = stack_of_books.pop() # Livro 1 {3}
# IndexError: pop from empty list
book = stack_of_books.pop() # Não há mais livros {4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment