Subscribe Us

Header Ads

How To Get Different Items Items Between Two List | interview questions

 Hey Guys in this video i am gonna tell you how you can get different items between two items...




Source Code...

#creating 2 list

list1 = [1, 2, 3, 2, 5, 6, 7, 8, 9]

list2 = [2, 4, 6, 8, 10, 10, 14]

#converting in set because set didn't contain duplicate items
set1 = set(list1)

set2 = set(list2)

#getting symmetric difference and converting in list
list3 = list(set1.symmetric_difference(set2))

#printing 3 list which have all different items..
print(list3)


Post a Comment

0 Comments