In Python, I have two lists
List1 = [1, 2] List2 = [3, 4]
How can I concatenate two lists in Python to get the below result!
List3 = [1, 2, 3, 4]
You have two options to perform merge or concatenate for two lists in Python:
Simply, you can use "+" operator.
list3=list1+list2 #the result is list3=[1, 2, 3, 4]
If you don't need to preserve the first list you can use "extend".
list1.extend(list2)
Hope it helps!
777 questions
506 answers
390 comments
619k users
Related Activities
Most popular tags
deBUG.to Shortcuts
Categories