We need to take two lists in Python and merge them into one. Finally, we display the sorted list.
Input : list1 = [25, 18, 9, 41, 26, 31] list2 = [25, 45, 3, 32, 15, 20] Output : [3, 9, 15, 18, 20, 25, 25, 26, 31, 32, 41, 45] Input : list1 = ["suraj", "anand", "gaurav", "aman", "kishore"] list2 = ["rohan", "ram", "mohan", "priya", "komal"] Output : ['aman', 'anand', 'gaurav', 'kishore', 'komal', 'mohan', 'priya', 'ram', 'rohan', 'suraj']
The plus operator “+” in Python helps us to merge two lists, be it a list of string or integers or mixture of both. Finally, we sort the list using the sort() function.
[3, 9, 15, 18, 20, 25, 25, 26, 31, 32, 41, 45]
- Creating Pandas dataframe using list of lists
- Python | Creating DataFrame from dict of narray/lists
- Python | Program to count number of lists in a list of lists
- Python | Creating a 3D List
- Python | Combining two sorted lists
- Python | Merge List with common elements in a List of Lists
- Python | Sorting list of lists with similar list elements
- Python | Maximum sum of elements of list in a list of lists
- Python | Check if a list exists in given list of lists
- Python | Convert List of lists to list of Strings
- Python | Ways to sum list of lists and return sum list
- Python | Convert list of string into sorted list of integer
- Python | Convert list into list of lists
- Python | Indices of sorted list of list elements
- Creating a Pandas Series from Lists
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.