w3resource

Python: Append a list to the second list

Python List: Exercise - 24 with Solution

Append One List to Another

Write a Python program to append a list to the second list.

Example - 1 :

Python: Append a list to the second list

Example - 2 :

Python: Append a list to the second list

Example - 3 :

Python: Append a list to the second list

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

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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/python-exercises/list/python-data-type-list-exercise-24.php