LIST CONCATENATION
List concatenation in Python allows you to combine two or more lists into a single, longer list using the + operator. When two lists are added together, Python creates a brand-new list containing all the elements of the first list followed by all the elements of the second. The original lists remain unchanged, since concatenation produces a new sequence rather than modifying either operand in place. This makes list concatenation a simple and intuitive way to merge collections of items while preserving the ordering of each list.
fruits1 = ["apple", "banana"]
fruits2 = ["cherry", "date"]
all_fruits = fruits1 + fruits2
print(all_fruits) # Output: ["apple", "banana", "cherry", "date"]input1 = list(map(str, input().split()))
input2 = list(map(str, input().split()))
print(input1 + input2)
* INPUT
dog cat
cow buffalo
* OUTPUT
['dog', 'cat', 'cow', 'buffalo']Last updated