List syntax

In Python programming, a list is created by enclosing all elements in square brackets, separated by commas.

A list can contain any number of elements and they can be of different types (integer, float, string, etc.). A list can even contain another list.

myEmptyList = []
myHomList = [1, 2, 3, 4, 5]
myHomList = ['A', 'B', 'C']
myHetList = [[1, 2, 3], 'A', "Hello"]

Example: print list

myList = [1, 2, 3, 4, 5]

for i in myList:
    print(i, end=" ")

print("\n" + str(myList[0]))
print(myList[1])
print(myList[2])
Output
1 2 3 4 5 
1
2
3