How do I concatenate two lists in Python?
Here how we do concatenate two lists in Python.
Concatenation of a list means joining two different lists. And if we want to concatenate two lists in python we have to use an operator. That operator is ‘+ ‘. We have to use the plus operator if we want to contact two lists.
use of the +
the operator is as follow:
listone = [1, 2, 3] listtwo = [4, 5, 6] joinedlist = listone + listtwo
So here we will have an output as :
>>> joinedlist
[1, 2, 3, 4, 5, 6]
Also read, How to make Git “forget” about a file that was tracked