TOPIC 5: Python Lists
Completion requirements
1. Python Lists
Introduction
Lists are used to store multiple items in a single variable.
In Python, a List is one of the built-in data types used to store collections of data. Instead of creating multiple variables to store related information, we can store them together in a single list.
For example, instead of writing:
fruit1 = "apple"
fruit2 = "banana"
fruit3 = "cherry"
We can store all the values in a single list:
fruits = ["apple", "banana", "cherry"]
Lists are created using square brackets [].
Example:
thislist = ["apple", "banana", "cherry"]
print(thislist)
Output:
['apple', 'banana', 'cherry']