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?
python append elements
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']
Test your knowledge with interactive quizzes.
Prepare for interviews with curated question sets.
Ask your coding-related doubts and get answers.
Earn certifications to enhance your resume.
Hands-on projects to improve your skills.
Test your knowledge with interactive quizzes.
Prepare for interviews with curated question sets.
Add your technical blogs and read technical topics.
Earn certifications to enhance your resume.
Hands-on projects to improve your skills.