- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python - Insert list in another list
A list also the extend() method, which appends items from the list you pass as an argument. extend() − Python list method extend() appends the contents of seq to list. You can read more about it here "https://www.tutorialspoint.com/python/list_append.htm"
Now let us see hands on
#append first_list = [1,2,3,4,5] second_list = [6,7,8,9,10] first_list.append(second_list) # print result using 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]
- How to remove index list from another list in python?
- Python - Check if a list is contained in another list
- Update a list of tuples using another list in Python
- How do I insert all elements from one list into another in Java?
- Python program to mask a list using values from another list
- Python - First occurrence of one list in another
- list insert( ) in C++ STL
- How can I sort one list by values from another list in Python?
- Python program to insert an element into sorted list
- Python program to get the indices of each element of one list in another list
- How to copy a list to another list in Java?
- How to Split given list and insert in excel file using Python?
- How to insert elements in C++ STL List?
- How to insert an object in a list at a given position in Python?
- Insert the string at the beginning of all items in a list in Python