+ 1
Combine lists
How do I combine lists so that each element of each list appears only once?
2 Respuestas
+ 7
Sonja ,
thera are many ways to accomplish this task. 2 of them are:
lst1 = [1, 2, 3, 4]
lst2 = [4, 5, 2, 7]
result should be: [1, 2, 3, 4, 5, 7]
(1) we can use the plus operator to merge lst1 and lst2. then make the resulting list a set, and convert it back to a list.
(2) we can use a for loop. append elements from lst2 to lst1 only if these elements don't exist already in in lst1
+ 1
Hi! You can Google all your questions
https://datagy.io/JUMP_LINK__&&__python__&&__JUMP_LINK-combine-lists/