List function in the python programming.


Let's understand the application's of the list function in the python programming.


 List is used for defining the number of objects different objects in our day to day life it is very simple to understand the function of the list by simple way.

so let the one example of the list 
list_1=['blogger', '1','2','3']
here list contains the 4 elements and there index is start from the 0 upto n-1 (here n is total number elements ).

list is mutable so we can change the list as we want .

  1. To calculate the number of elements in the list we use the len() function
  2. If the list contains the strings then if we want to change the elements in the list as upper case and the lower case then we use the upper() and lower()
  3. To add the any element in the list then use the like as given example I want add the 7 in the list_1[0]=7  output is  list_1=[7,'blogger', '1','2','3'] it add at the zeroth index.
  4. capitalize is the function which convert the all the strings first character to the upper case(only the first character).If the list contains the repeated characters and if you want to calculate how many times the character is repeated just use the count function ,count()                                  

list_2=[1,1,2,2,2,3,4,5,5,5]
print(list_2.count(1)) #output=2
print(list_2.index(2))    it finds the position of 
element in the list   #output=2 
    For the finding the more information click here                        

Post a Comment

Previous Post Next Post