MPDA’22
October 28, 2021
python
In python, lists are defined using square brackets []
.
You can also access items on a list individually…
…and in ranges of indexes separated by :
append()
functionAdding objects to the end of a list
insert()
functionAdding an item at a specified index
remove()
functionRemoving an item from a list
pop()
functionRemoving an item from a specified index
or the last index if no index is provided.
range()
functionThe range()
function returns a sequence of numbers…
len()
functionThe len()
function returns the current length of a list:
loops
?In computer science, a loop
is a programming structure that repeats a sequence of instructions until a specific condition is met.
Print each fruit in a fruit list
You can also loop through the letters of a word
loops
can be nested
and combined with conditionals