I have a problem matching lists in python.
list1 = [["id1","string1","string2"],["id2","string3","string4"]]
list2 = [["id1","string1","string2", "string3"],["id3","string4","string5", "string6"]]
I want something like this
list3 = [["id1", "string1", "string2", "string3"],["id2","string3","string4"],["id3","string4","string5", "string6"]]
if an id from list1 is in list2 then write the element from list2 (e.g. ["id1","string1","string2"]
) to a new list. If it's not in the list take the element from list1 and write it to the new list. At the end the result should look something like this
I tried it this way
for p in list1:
for d in list2:
if ( (p[0] in list2)):
list3.append(d)
next
else:
list3.append(p)