Python Code Example: Join two Lists

In this code, two lists firstList and secondList are defined with elements [1, 2, 3, 4, 5] and [6, 7, 8, 9, 10] respectively.

A third list joinedList is created by concatenating firstList and secondList using the + operator.

The + operator performs the concatenation of the two lists by combining all the elements of the first list followed by all the elements of the second list, resulting in a new list joinedList with elements [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].

Finally, the joinedList is printed using the print() function.

firstList = [1, 2, 3, 4, 5]
secondList = [6, 7, 8, 9, 10]

joinedList = firstList + secondList

print(joinedList)
Output
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]