The data type list allows manipulation of its contents through various operations concatenation, repetition, membership and slicing.

Concatenation

Python allows us to join two or more lists using the concatenation operator depicted by the symbol ‘+’.

Concatenation - Teachoo.jpg

 

Lists l1 and l2 remain the same after the concatenation operation.

Repetition

Python allows us to replicate a list using repetition operator depicted by symbol *.

Repetition - Teachoo.jpg

Membership

In operator

The membership operator ‘in’ checks if the element is present in the list and returns True, else returns False.

Membership - Teachoo.jpg

 

Not in operator

The not in operator returns True if the element is not present in the list, else it returns False.

Not in operator - Teachoo.jpg

 

Slicing

In Python, to access some part of a list , we use a method called slicing. This can be done by specifying an index range. 

Syntax:

List[ Initial : End : IndexJump ]

 

Slicing - Teachoo.jpg Slicing 1 - Teachoo.jpg

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.