How to add/multiply two lists together with plus sign in Python

Add two list together with +

We can add two lists together by using plus operator.


print [1, 2, 3] + [4, 5, 6] 

The code above generates the following result.

Multiply a List

Multiplying a list by a number x creates a new list where the original list is repeated x times.


print [42] * 10 

The code above generates the following result.





















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary