“como excluir o último item em uma lista python” Respostas de código

como excluir o último item em uma lista python

# The pop function, without an input, defaults to removing 
# and returning the last item in a list.
myList = [1, 2, 3, 4, 5]
myList.pop()
print(myList)

# You can also do this without returning the last item, but it is
# much more complicated.
myList = [1, 2, 3, 4, 5]
myList.remove(myList[len(myList)-1])
print(myList)
Jittery Jellyfish

Python Remova o último elemento da lista

record = record[:-1]
Anxious Ant

Exclua os últimos itens de uma lista python

# Remove the last 3 items from a list
x = [1, 2, 3, 4, 5]
for i in range(3): x.pop()
Excited Earthworm

Respostas semelhantes a “como excluir o último item em uma lista python”

Perguntas semelhantes a “como excluir o último item em uma lista python”

Procure respostas de código populares por idioma

Procurar outros idiomas de código