Mega Code Archive

 
Categories / Python / List
 

Sort elements in a list

L = ['spam', 'Spam', 'SPAM!'] print L.append('please')                # append method call print L L.sort()                          # sort list items ('S' < 'e') print L