Checkpoint 27.5.1.
This program adds two strings to the list
words
. Add code to add the word “Carrot” to the list after “Banana” but before “Date”[]
as our list. And then we can use append
to add things to the end of the list.words
. Add code to add the word “Carrot” to the list after “Banana” but before “Date”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:pop()
removes an item from the end of a list. (It “pops” the item off.)pop(index)
removes an item from the specified index.remove(value)
removes the first copy of the specified value from the list.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.