“Python Pop -Element” Code-Antworten

Python Pop -Element

my_list = [123, 'Add', 'Grepper', 'Answer']
my_list.pop()
-->[123, 'Add', 'Grepper'] #last element is removed

my_list = [123, 'Add', 'Grepper', 'Answer']
my_list.pop(0)
-->['Add', 'Grepper', 'Answer'] #first element is removed

my_list = [123, 'Add', 'Grepper', 'Answer']
any_index_of_the_list = 2
my_list.pop(any_index_of_the_list)
-->[123, 'Add', 'Answer'] #element at index 2 is removed 
						  #(first element is 0)
Outrageous Oryx

Entfernen Sie ein Element aus einer Python -Liste mithilfe der POP () -Methode

List = [1,2,3,4,5]
 
# Removing element from the
# Set using the pop() method
List.pop()
print("\nList after popping an element: ")
print(List)
 
# Removing element at a
# specific location from the
# Set using the pop() method
List.pop(1)
print("\nList after popping a specific element: ")
print(List)
Outrageous Ostrich

Ähnliche Antworten wie “Python Pop -Element”

Fragen ähnlich wie “Python Pop -Element”

Weitere verwandte Antworten zu “Python Pop -Element” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen