Lists in Python

The list is a compound data type which is used to group several items together.

It might contain items of different data types.

Lists are mutable which means we can change the list contents.




List Syntax

variable = [item1, item2, ..itemN]

Items should be separated by comma (,) and enclosed within square brackets.

Example

numbers = [0, 1, 2, 3, 4,5]       #same data type  
data    = ["Python", 3.64, 2018]  #different data type



Printing the list elements

Example

#Python List Example

numbers = [0, 1, 2, 3, 4,5]       #same data type  
print(numbers)

data    = ["Python", 3.64, 2018]  #different data type
print(data)