List in Python        


Lists


It can be written as a list of comma-separated values within square brackets. Multiple types of data can be stored in a List.
Individual elements of a list can be changed (it can be read and write).
Syntax:
Name_of_list=[ values,values2…….]
Value can be string, numbers or mixtures.



Ø Accessing values in Lists:

Square brackets are used to access the values of a list. We can access a specific value or range of values from the list.

 




Ø Updating Lists:

We can update single or multiple elements of a list by giving slice on the left hand of the assignment operator. It can also be updated using the append () function.


Ø Delete List element:

del statement is used to remove when you know the position or index of the element to be deleted.

Remove () function can be used when you don't know the position of element to be removed.


           




Post a Comment

Previous Post Next Post