How do I concatenate two lists in Python?
Example:
listone = [1, 2, 3]
listtwo = [4, 5, 6]
Expected outcome:
>&g
I assume you are wanting one of the two methods:
Keep Duplicate elements
It is very easy, just concatenate like string:
def concat_list(l1,l2):
l3 = l1+l2
return l3
Next if you want to eliminate duplicate elements
def concat_list(l1,l2):
l3 = []
for i in [l1,l2]:
for j in i:
if j not in l3:
#Check if element exists in final list, if no then add element to list
l3.append(j)
return l3