Line At A Time
Lesson 14: Lists
Lists Store several values in one variable.
1fruits = ["apple", "banana", "cherry"]
2print(fruits)
Terminal
$ python3 main.py
['apple', 'banana', 'cherry']
Every line, explained
fruits = ["apple", "banana", "cherry"]
A list stores several values in one variable. The values go between square brackets, separated by commas. Lists are one of Python's favourite tools, and unlike some languages, you can print one directly and see its contents.
print(fruits)
print(...) shows whatever is inside its round brackets in the terminal, then moves to a new line. It is written all in lowercase, and it needs both brackets. Printing a list shows all of its items between square brackets. (Python shows the strings with single quotes; that's just its style when displaying a list.)