Python includes the following list functions −
Sr.No | Function with Description |
---|---|
1 | cmp(list1, list2) Compares elements of both lists. |
2 | len(list) Gives the total length of the list.p> |
3 | max(list) Returns item from the list with max value. |
4 | min(list) Returns item from the list with min value. |
5 | list(seq) Converts a tuple into list. |
Python includes following list methods
Sr.No | Methods with Description |
---|---|
1 | list.append(obj) Appends object obj to list |
2 | list.count(obj) Returns count of how many times obj occurs in list |
3 | list.extend(seq) Appends the contents of seq to list |
4 | list.index(obj) Returns the lowest index in list that obj appears |
5 | list.insert(index, obj) Inserts object obj into list at offset index |
6 | list.pop(obj=list[-1]) Removes and returns last object or obj from list |
7 | list.remove(obj) Removes object obj from list |
8 | list.reverse() Reverses objects of list in place |
9 | list.sort([func]) Sorts objects of list, use compare func if given |