Chapter 8: Lists Flashcards
A circumstance where two or more variables refer to the same object.
aliasing
A character or string used to indicate where a string should be split.
delimiter
One of the values in a list (or other sequence); also called items.
element
Having the same value.
equivalent
An integer value that indicates an element in a list.
index
Being the same object (which implies equivalence).
identical
A sequence of values.
list
The sequential accessing of each element in a list.
list traversal
A list that is an element of another list.
nested list
Something a variable can refer to. Has a type and a value.
object
the relationship between indices and elements
eg. in a list
mapping
error type when you try to read or write an element that doesn’t exist
IndexError
for loop function that iterates through the number of times specified by an integer
range()
operator to concatenate lists
creates a new list
+
operator to repeat a list n times
creates a new list
*
method to update multiple list elements at once
creates a new list
slice
nums[1:3] = [5,6]
method to add one new element to end of list
modifies existing list
.append()
method to add list with multiple new elements to end of list
modifies existing list
.extend([list])
method to arrange list from lowest to highest
.sort()
method that removes indexed element from list and returns value
default removes last element
modifies existing list
.pop()
eg. pop.(2)
statement that takes element off of list based on index
returns None
del
eg. del t[1]
del t[1:5]
function to take element off of list based on its value
returns None
remove
eg. remove(‘b’)
function that returns accumulated value of list elements
sum()
function that returns number of elements in list
len()
function to convert a string to a list
list()
function to convert a string into a list of words based on a delimiter.
default delimiter is a space
.split()
string method that takes a list of strings and concatenates them together with a delimiter.
Method called on the delimiter and list passed as parameter
.join()
’ ‘.join(string_list)
function that returns new list in order and leaves the original alone
sorted()