List Type Built-in Methods

You may recall our earlier discussion of accessing object attributes using the dotted attribute notation: object.attribute. List methods are no different, using list.method([arguments]). We use the dotted notation to access the attribute (here it is a function), then use the function operators ( ( ) ) in a functional notation to invoke the methods.
Types that have methods generally have an attribute called object.__methods__ which name all the methods that are supported by that type. In our case for lists, list.__methods__ serves this purpose.
Following table demonstrates the methods used with lists :

Format Symbol Conversion

appends object obj to list

returns count of how many times obj occurs in list

appends the contents of seq to list

returns the lowest index in list that obj appears
list.insert(index, obj)

inserts object obj into list at offset index

removes and returns last object or obj from list

removes object obj from list

reverses objects of list in place

sorts objects of list, use compare func if given

You may also like...

No © Loop and Break