Lists in Python

A list is just like an array i.e. an ordered sequence of items. Ordered sequence means items are ordered from 0 to n.

Items in list can be of different types i.e. not all items need to be of same data type. Declaring a list is just like declaring another variable in python. The only difference is how the values are assigned to it.

e.g. myList = [1, 2, “Three”, True]

First two elements are numbers, then it’s a string and the last one is of boolean type

Items in the list can also be lists i.e. lists can be nested. Items in nested lists are accessed with an additional index position specified in brackets

Leave a Reply