Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Lists in python
  5. Introduction of list in python

Introduction of list in python

A list is a data structure, or it can be considered a container that can be used to store multiple data at once.

The list will be ordered and there will be a definite count of it. Python lists are mutable.

The elements are indexed according to a sequence and indexing is done with 0 as the first index. Each element will have a distinct place in the sequence and if the same value occurs multiple time in the sequence, each will be considered separate and distinct element.

To create a list, put a number of expressions in square bracket. That is use square bracket to indicate the start and end of the list, and separate the items by commas.


l=['1', '2', '3', '4', '5']
Output- class <list>

A list can have an element in it, which itself is a list. Such list is called nested list.

l=[1, 2, 3, 4, [5, 6], 7, 8]
Output- class <list>
Was this article helpful to you? Yes No

How can we help?