24 CORSO DI PROGRAMMAZIONE I metodi sulle liste in Python

The video presents several methods that work on lists, such as: l.append(a) Adds element a to the end of list l l.insert(n, a) Adds element a to position n in the list (positions are numbered from 0, see below) l.remove(a) Removes element a from list l. If a is not in the list, it raises a ValueError. l.sort() Sorts the elements of the list alphabetically or numerically. l.reverse() Reverses the order of the elements of the list. l.count(a) Returns (as an int) the number of occurrences of a in the list (i.e., how many times element a appears in l, 0 if it is not present). l.pop(a) l.pop() Removes element a from the list and returns it as the result of the function. Used without a parameter, it removes the last element. l.clear() Clears all elements: list l becomes empty. len max min sum