Methods in List in Python.


Lists Method:


testing=[12,23,21,43,232,656,43]

Len() : returns how many elements are in a list.

max(): returns the greatest element of the list. How the greatest element is determined depends on what type objects are in the list. The maximum element in a list of numbers is the largest number. The maximum elements in a list of strings are an element that would occur last if the list were sorted alphabetically. This works because the max function is defined in terms of the greater than comparison operator. The max function is undefined for lists that contain elements from different, incomparable types.

min(): returns the smallest element in a list. min is the opposite of max, which returns the 
the largest element in a list.

sorted(): returns a copy of a list in order from smallest to largest, leaving the list unchanged.


Some other functions of List:


Real implementation of Lists Method:





Post a Comment

0 Comments