एक सूची में extend() विधि भी होती है, जिसे आप एक तर्क के रूप में पास की गई सूची से आइटम जोड़ते हैं। extend() − Python सूची विधि extend() सूची में seq की सामग्री जोड़ती है। आप इसके बारे में यहां और पढ़ सकते हैं "https://www.tutorialspoint.com/python/list_append.htm"
अब आइए हाथों-हाथ देखें
उदाहरण
#append first_list = [1,2,3,4,5] second_list = [6,7,8,9,10] first_list.append(second_list) # append का उपयोग करके परिणाम प्रिंट करें print("The list pattern using append is : " + str(first_list)) #extend third_list_ = [11,12,13,14,15] fourth_list = [16,17,18,19,20] third_list_.extend(fourth_list) print("The list pattern using extend is : " + str(third_list_))आउटपुट
The list pattern using append is : [1, 2, 3, 4, 5, [6, 7, 8, 9, 10]] The list pattern using extend is : [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]