Sometimes, we do not know all of the items in a list in advance - we want to build up a list as the program is running. To do this, we can start with a blank list using [] as our list. And then we can use append to add things to the end of the list.
It is also possible to add items to locations other than the end of the list by using the insert function. To use it, we provide an index of where to insert the new value with the value we want to insert. Try running this sample with codelens:
What happens if you use an index that does not exist to insert? Change the last insert in the sample above to insert at location 200 instead of 2. What happens?
We want the list called alphabet to contain the letters βAβ, βBβ, βCβ, βDβ in that order. Use a combination of append, insert, remove, and pop to make it have the right values.
The following program should make the discounts list contain the values of all the items from price_list after they have been discounted by 50%. To do so, we need to loop through the original prices, calculate the discounted price, then append it to the discount list.