Python merge two lists (arrays)

To merge two (or more) lists (arrays) the operator plus (+) can be used. It will append items of 2nd list to first list and return new list.

newlist = list1 + list2


a1 = ["v1", "v2"]
a2 =  ["v3", "v4"]
newlist = a1 + a2
print newlist
Env: Python 2.7.6
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments