Python Practice › List Programs › Program 23
Add two lists with extend()
Write a Python program to add one list to another with extend().
Input
[1, 2], [3, 4]
Output
[1, 2, 3, 4]
Approach
a.extend(b)adds every item of b to a.
Solution
a = [1, 2]b = [3, 4]a.extend(b)print(a)Output
[1, 2, 3, 4]
Learn the concept
New to this topic? Read the lesson, then come back.