Python Practice › List Programs › Program 23

Add two lists with extend()

EasyList Programs · 23 of 100

Write a Python program to add one list to another with extend().

Advertisement
Input
[1, 2], [3, 4]
Output
[1, 2, 3, 4]

Approach

  1. a.extend(b) adds every item of b to a.

Solution

Python
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.

More list programs

← All 100 List Programs

Leave a Comment