September 2018
Intermediate to advanced
472 pages
12h 2m
English
Lists are collections of elements. Elements can be integers, floats, strings, or generically, objects. Moreover, you can mix different types together. Besides, lists are more flexible than arrays because arrays allow only a single datatype. To create a list, you can either use the square brackets or the list() constructor, as follows:
a_list = [1, 2.3, 'a', True]an_empty_list = list()
The following are some handy methods that you will need to remember while working with lists:
a_list[1] # prints 2.3 a_list[1] = 2.5# a_list is now [1, 2.5, 'a', True]
Read now
Unlock full access