Nuttige ingebouwde functies for lists Flashcards
my_list.append()
add the item at the end of the list
my_list.clear()
clears a whole list
my_list.copy()
copies the old list, doesn’t update it
my_list.count(‘Bob’)
you get the amount of Bob’s in the list
my_list.extend()
add elements of a list to another list, make it one list
my_list.index(‘Bob’)
you get the index number of Bob in the list
my_list.insert(i, b)
insert item b at the position of i
my_list.pop(i)
remove i’th element from list and return it, otherwise delete
last element
my_list.remove(x)
remove it from the list
print(len(my_list))
aantal indexes
my_list.reverse()
revers the list (NO RETURN VALUE)
my_list.sort()
sorts the elements of the list
print(max(my_list))
hoogste cijfer uit de lijst
print(min(my_list))
laagste cijfer uit de lijst
print(sum(my_list))
alles bij elkaar opgeteld