The data type list is an ordered sequence which is mutable and made up of one or more elements.

  • A list can have elements of different data types , such as integer, float, string, tuple or even another list. 
  • A list is very useful to group together elements of mixed data types. 
  • Elements of a list are enclosed in square brackets and are separated by comma. 
  • Like string indices, list indices also start from 0.

Accessing elements in a List

The elements of a list are accessed in the same way as characters are accessed in a string. 

The list items are accessed by referring to the index number in square brackets. 

 

Accessing elements - Teachoo.jpg

Accessing elements 1 - Teachoo.jpg

 

Lists are Mutable

In python, lists are mutable ie.,  the contents of the list can be changed after it has been created.

Lists are Mutable - Teachoo.jpg

Go Ad-free
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 and Computer Science at Teachoo