Now that we have finished working on numbers and strings, let's work with the lists and sublists.


Python lists are data structures that group sequences of elements. Lists can have elements of several types, and you can also mix different types within the same list (although all elements are usually of the same datatype).

Lists are created using square brackets [], and the elements are separated by commas (,). The elements in a list can be accessed by their positions, starting with 0 as the index of the first element.


For example, to create list l with five elements, write


Get hands-on with 1000+ tech skills courses.