Python Listesi pop() Yöntem
Örnek
fruit
Listenin ikinci öğesini kaldırın :
fruits = ['apple', 'banana', 'cherry']
fruits.pop(1)
Tanım ve Kullanım
Yöntem pop()
, öğeyi belirtilen konumda kaldırır.
Sözdizimi
list.pop(pos)
Parametre Değerleri
Parameter | Description |
---|---|
pos | Optional. A number specifying the position of the element you want to remove, default value is -1, which returns the last item |
Daha fazla örnek
Örnek
Kaldırılan öğeyi döndür:
fruits = ['apple', 'banana', 'cherry']
x =
fruits.pop(1)
Not: Yöntem pop()
, kaldırılan değeri döndürür.