Metoda insert() seznamu Pythonu
Příklad
Vložte hodnotu "oranžová" jako druhý prvek fruit
seznamu:
fruits = ['apple', 'banana', 'cherry']
fruits.insert(1, "orange")
Definice a použití
Metoda insert()
vloží zadanou hodnotu na zadanou pozici.
Syntax
list.insert(pos, elmnt)
Hodnoty parametrů
Parameter | Description |
---|---|
pos | Required. A number specifying in which position to insert the value |
elmnt | Required. An element of any type (string, number, object etc.) |