Python List insert() Metodo
Esempio
Inserisci il valore "arancione" come secondo elemento della fruit
lista:
fruits = ['apple', 'banana', 'cherry']
fruits.insert(1, "orange")
Definizione e utilizzo
Il insert()
metodo inserisce il valore specificato nella posizione specificata.
Sintassi
list.insert(pos, elmnt)
Valori dei parametri
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.) |