Given two lists, the task is to combine two lists and removing duplicates, without removing duplicates in original list.
Input : list_1 = [11, 22, 22, 15] list_2 = [22, 15, 77, 9] Output : OutList = [11, 22, 22, 15, 77, 9]
Code #1: using extend
[111, 222, 222, 115, 77, 19]
Code #2 : Using Set and Iteration
Append those element in first list which are not in second list and then take union of first and second list.
[11, 22, 22, 15, 9, 77]
- Python | Maintaining Grocery list
- Python | Pair and combine nested list to tuple list
- Python | Inserting item in sorted list maintaining order
- Python | Difference of two lists including duplicates
- Python | Program to count number of lists in a list of lists
- Python | Merging duplicates to list of list
- Python | Remove Duplicates from a List
- Python | Sorting list of lists with similar list elements
- Python | Merge List with common elements in a List of Lists
- Python | Ways to remove duplicates from list
- Python | Remove duplicates from nested list
- Python | Remove consecutive duplicates from list
- Python | Ways to sum list of lists and return sum list
- Python | Maximum sum of elements of list in a list of lists
- Python | Check if a list exists in given list of 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.