Anyone Can Code.
A list is an ordered sequence of data which is mutable (it's values can be overwritten) and can
also contain multiple data types. For example, we can have lists with strings, ints, floats,
To create a list, we use Square Brackets
An example of a list with identifier
We can also create lists as elements of lists. These are known as nested lists.
list2 = [3,4,[5,6],7]nests the list
To access elements in a list, we use indexing, the same thing we did with strings, but here each index represents an element in a list whereas in a string each index represented a character in the string.
Lists are mutable data types and their contents can be overwritten.
[3, 4, 5, 6] [3, 4, 5, 4]
Here you can see we gave a new value to the fourth element in the list. This was only possible due to the mutable nature of lists.
That's it for this tutorial! Scroll up and click on Next for the next tutorial!