पायथन सूची का विस्तार () विधि
उदाहरण
के तत्वों को cars
सूची में जोड़ें fruits
:
fruits = ['apple', 'banana', 'cherry']
cars = ['Ford', 'BMW', 'Volvo']
fruits.extend(cars)
परिभाषा और उपयोग
extend()
विधि वर्तमान सूची के अंत में निर्दिष्ट सूची तत्वों (या किसी भी चलने योग्य) को जोड़ती है ।
वाक्य - विन्यास
list.extend(iterable)
पैरामीटर मान
Parameter | Description |
---|---|
iterable | Required. Any iterable (list, set, tuple, etc.) |
और ज्यादा उदाहरण
उदाहरण
सूची में एक टपल जोड़ें fruits
:
fruits = ['apple', 'banana', 'cherry']
points = (1, 4, 5, 9)
fruits.extend(points)