15.9. Chapter Concept Summary¶
This chapter included the following concepts from computing.
Append - To append means to add something to the end
List - A list holds items in order. An example of a list is
[1, "hi", 3]
. Lists in Python can hold any type of data.Index - The index is the position of the item in a list or string. In Python the first item is at index 0.
15.9.1. Summary of Python Keywords and Functions¶
len - The
len
(length) function returns the number of items in a collection (a string or a list). It is used like:len(list)
append - Adds an item to the end of a list:
list.append(item)
insert - Adds an item to the specified position of a list:
list.insert(0, item)
adds the item at the start of the list.pop - Removes an item from the specified position of a list:
list.pop(1)
removes the second item (index 1). When called without an index,list.pop()
, it removes the last thing.remove - Removes the first copy of the specified item from the list.
list.remove("A")
would remove the first “A” from the list.