पायथन सूची सम्मिलित करें () विधि
उदाहरण
सूची के दूसरे तत्व के रूप में "नारंगी" मान डालें fruit
:
fruits = ['apple', 'banana', 'cherry']
fruits.insert(1, "orange")
परिभाषा और उपयोग
insert()
विधि निर्दिष्ट स्थान पर निर्दिष्ट मान सम्मिलित करती है ।
वाक्य - विन्यास
list.insert(pos, elmnt)
पैरामीटर मान
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.) |