9.6. List methodsΒΆ

Python provides methods that operate on lists. For example, append adds a new element to the end of a list:

extend takes a list as an argument and appends all of the elements:

This example leaves t2 unmodified.

sort arranges the elements of the list from low to high:

Most list methods are void; they modify the list and return None. If you accidentally write t = t.sort(), you will be disappointed with the result.

You have attempted of activities on this page