Python: Append a list to the second list
Python List: Exercise - 24 with Solution
Write a Python program to append a list to the second list.
Example - 1 :
![Python: Append a list to the second list](https://www.w3resource.com/w3r_images/Python-data-type-list-excercise-24.png)
Example - 2 :
![Python: Append a list to the second list](https://www.w3resource.com/w3r_images/Python-data-type-list-excercise-24-a.png)
Example - 3 :
![Python: Append a list to the second list](https://www.w3resource.com/w3r_images/Python-data-type-list-excercise-24-b.png)
Sample Solution:
Python Code:
# Define a list 'list1' containing numeric elements
list1 = [1, 2, 3, 0]
# Define another list 'list2' containing string elements
list2 = ['Red', 'Green', 'Black']
# Concatenate 'list1' and 'list2' to create a single list 'final_list'
final_list = list1 + list2
# Print the 'final_list,' which contains elements from both 'list1' and 'list2'
print(final_list)
Sample Output:
[1, 2, 3, 0, 'Red', 'Green', 'Black']
Flowchart:
![Flowchart: Append a list to the second list](https://www.w3resource.com/w3r_images/python-data-type-list-exercise-24.png)
Python Code Editor:
Previous: Write a Python program to flatten a shallow list.
Next: Write a Python program to select an item randomly from a list.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics