Python - List method call


List method call


L = ['eat', 'more', 'TEST!'] 
L.append('please')                # Append method call: add item at end 
print( L )
L.sort()                          # Sort list items ('S' < 'e') 
print( L )


List method append() adds a single item onto the end of the list.

Unlike concatenation, append expects you to pass in a single object, not a list.

The effect of L.append(X) is similar to L + [X],

The sort method orders the list's items here.

Related Topic