python append elements from one list to anoter 1

python append elements from one list to anoter

x = [1, 2, 3]
x.extend([4, 5])
x

Here is what the above code is Doing:
1. We create a list called x and assign it the values 1, 2, and 3.
2. We call the extend() method on x, and pass it the list [4, 5].
3. The extend() method appends the elements of the list [4, 5] to the end of the list x.

Similar Posts