The function of operator + is used to merge two lists into one.
Example
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
list1 = [0,1, 2, 3, 4, 5, 6, 7]
list2 = [ 4, 5, 6, 7]
print("the list1 is: ",list1)
print("the list2 is: ",list2)
list3=list1+list2
print("the list1 + list2 is: ",list3)
Output:
the list1 is: [0, 1, 2, 3, 4, 5, 6, 7]
the list2 is: [4, 5, 6, 7]
the list1 + list2 is: [0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7]
Syntax
list1+list2
Parameters
Name | Description |
list1 | A list |
list2 | A list |
Return Value
It returns a new list.