Waiting Answer October 02, 2024

How To Append Elements Of One List Into Another List Using Python

Here is List1,

    list1 = ["Red", "Blue", "Green"]

and list2

    list2 = ["Silver","Yellow","Gray"]

I want to append the elements of list1 into list2 and the result should be in list1. How it is possible in Python?

Answers
2024-10-02 12:16:00

Using the extend() method in Python, You can append the elements of one list to another list. In your case


         list1 = ["Red", "Blue", "Green"]
         list2 = ["Silver","Yellow","Gray"]

         list1.extend(list2)

         print(list1)

Output:

         ['Red', 'Blue', 'Green', 'Silver', 'Yellow', 'Gray']