list.py
= ["cat", "dog", "horse", 7, "quail"]
my_list
print(my_list)
We have changed our list by adding two more items to the end of it. We add an integer, 7
and a new string, "quail"
. Each is still separated by a comma:
list.py
= ["cat", "dog", "horse", 7, "quail"]
my_list
print(my_list)
Terminal/Command Prompt
python list.py
['cat', 'dog', 'horse', 7, 'quail']
Here we edit our list so that the items are all in a different order:
list.py
= ["quail", "cat", 7, "dog", "horse"]
my_list print(my_list)
['quail', 'cat', 7, 'dog', 'horse']