How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Python concatenate lists operator with basic syntax and many examples for better understanding.
Python concatenate lists (+) is used to add two lists and create a new list value .
Syntax:
(list_variable_name1) + (list_variable_name2) + (list_variable_name3) + .......
Input Parameters:
- list_variable_name1 & list_variable_name2 : The lists that we want to be concatenated.
Example
versions=[0.1,0.2]
browsers=['crome','mozilla', 'ie']
# list after concatenation
newList=versions+browsers
print('New list:',newList)
Output
New list: [0.1, 0.2, ‘crome’, ‘mozilla’, ‘ie’]
In the above Example, by using concatenation operator (+), we have added two lists ‘versions’ and ‘browsers ‘ as versions+browser in print statement, and created new list as [0.1, 0.2, ‘crome’, ‘mozilla’, ‘ie’].
Note: Concatenation operator implies that both the operands passed must be list else error will be shown.
In this tutorial, you have learned how to concatenate two lists in python.
If you have an inquiry or doubt don’t hesitate to leave them in comment. we are waiting your feedback.But remember to understand the concept very well, you need to practice more.
Hopefully, it was clear and concise.
Similar Python operators:
- Repetition(‘*’) : It repeats element of list.
- Membership(‘in’ & ‘not in’) : It returns True , if given element is present in list otherwise returns False.
- List Iteration : It returns element of list by using for loop with list.
Python tutorials list:
- Python tutorials list : access all python tutorials.