list1 = ["palani", "samy","be"]
list2 = ["palani", "samys","be"]
def find_common(list1,list2):
for x in list1:
for y in list2:
if x == y :
list2.remove(x)
print" unique string 1:",list1
print" unique string 2:",list2
print" combained string 2:",list1.append(list2)
find_common(list1,list2)
Why am I getting None
?
Python merges two lists without duplicates could be accomplished by using a set. And use the + operator to merge it.
You can also merge lists without duplicates in Google Sheets. Select and right-click a second range that will be merged (e.g., C2:C6) and click Copy (or use the keyboard shortcut CTRL + C).
On the Data tab, under Tools, click Consolidate. In the Function box, click the function that you want Excel to use to consolidate the data. In each source sheet, select your data, and then click Add.
Excel Combine List without Duplicates 1 Copy one of the two lists and paste it to the bottom of the other list, select the new list, then click 2 In the 3 Then a dialog pops up to tell you how many unique values have been selected, click 4 And copy the selected unique values and paste them to a new column ... See More....
How to Merge Two Lists in Excel 1 Copy one of the two lists and paste it to the bottom of the other list. 2 Select the list and click 3 In the 4 Then a dialog displays on the screen to tell you the duplicates have been delete, click See More....
How to combine two arrays without duplicate values in C#? Learn how to combine two arrays without duplicate values in C# using the Union () method. In the same way, use the Union () method with the number array. If an array contains objects of a custom class, then you need to implement IEquatable<T> or IEqualityComparer<T>, as shown below.
To delete the duplicates, click anywhere in the first list (B2:B15), and in the Ribbon go to Data > Remove Duplicates. 4. In the pop-up window, uncheck the second column and click OK.
This could be accomplished by using set:
a = ['hello', 'world']
b = ['hello', 'universe']
unique = list(set(a + b))
print(unique)
# ['universe', 'hello', 'world']
Note: this won't work for a list of dictionaries!
import numpy as np
np.unique(list1+list2) # keeps only non dublicates
this is also keeps the order incase that was a priority
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With