Please forgive me if there are some things that may not be achieved because I am a beginner.
If you print, you will see two lists as follows:
print(list1)
[['A', 'B', 'C', ['B', 'C', ['C', 'D']]]
print(list2)
['C', 'D']
["A", "B", "D"]
["A", "C", "F"]
List1 is a two-dimensional list, and list2 is a new line with multiple lists.
I want to compare list2 and list1 and remove duplicates from list2 (first list is between first list)
I would like the results to be as follows.
['D']
['A', 'D']
['A', 'F']
list1 = [['A', 'B', 'C', ['B', 'C', ['C', 'D']]
list2 = [['C', 'D', ['A', 'B', 'D', ['A', 'C', 'F']]
list_diff = [[*({*l2}-{*l1})] for l1, l2 in zip (list1, list2)]
print(list_diff)
# [[['D'], ['A', 'D'], ['A', 'F']]
© 2024 OneMinuteCode. All rights reserved.