Page 131 - Plus V4 with Adobe class 8
P. 131

The following table describes the various built-in methods:

                     Method                                       Explanation

                 append( )        Adds the element at the end of the existing list

                 extend( )        Adds more than one element to the end of the existing list
                 insert(x, a)     Inserts element ‘a’ at the ‘x’ location of the list

                 remove( )        Removes the first element from the list
                 index( )         Returns the index of the first element of the list

                 count( )         Returns the occurrence (number of times) of a particular element in the list
                 pop([i])         Removes and returns item at the ‘i’ location in the list

                 copy( )          Returns a copy of the list
                 clear( )         Removes all the elements from the list and returns an empty list

                 sort( )          Sorts all the elements in the list

                 reverse( )       Reverses the order of the elements in the list

            To use the built-in methods  on the list, follow the program as given below.























            On running the above program, you will get the following output:
















                     Factbot


             The ‘+’ operator when used with lists needs both the operands to be of list type, otherwise it will produce
             an error.




                                                                                                #List in Python 129
   126   127   128   129   130   131   132   133   134   135   136