Arrays [list] Methods For Python
1. append( ) method
to append an item to the end of the list
for example,
[Link]("color")
[Link]( ) method
to insert an item at any place in a list
for example,
[Link]'(1, "color")
3. extend( )
to append elements from another list
for example if you want to extend the thislist to hold values of mylist then,
[Link](mylist)
4. remove( ) method
to remove a specified item in a list
for example,
[Link]("banana") #the remove fucntion can only remove the
first instance of a given item duplicate remains.
5. pop( ) method
to remove a specified item with respect to it's index
for example,
[Link](1)
6. del method
to delete the whole list
for example,
del thislist
7. clear( ) method
to clear or empty the whole list
for example,
[Link]( )
8. reverse ( ) method
to reverse the order of the list
for example,
[Link]
9. sort ( ) method
sort the list ascending by default
forexample, # capital letters are always
written first, if the list contain [a, Z, e, c)
[Link]( ) # gives the list [ Z,a, c, e]
eventhough the desired result was [a, c, e, Z]
10. sort (key = [Link]) method
case-insensitive sorting
forexample,
[Link](key = [Link]) # this does give the result as [a, c, e, Z]
11. sort (reverse = True ) method
sort the list descendingly
for exampe,
[Link](reverse = True)
12. copy ( ) method
copy the contents of list to another list
for example,
thislist = [Link]( )