

You can also delete the complete list using the below command del city_list Emptying a list You can remove an item in a list by providing the item index or range that needs to be removed city_list= It is used to insert values at the provided index city_list=
#DICTIONARIES IN PYTHON UPDATE#
Num_list.extend()Ĭhange is used when you want to update a specific item in a list. city_list=Įxtend is used when you want to add more than one item to the list num_list= We will see all of them one by one.Īppend is used when you want to add one item to the list. One can append, extend, insert and change the lists. In updating the list there is various function.

The elements of a nested list can be accessed as shown below print(list_nest) In the below list there are two elements and both of them are list. Output Nested ListsĪ list is nested if another list is present inside it. The * operator is used to extend the list by copying the same values new_citylist= city_list*2 The + operator concatenates both the lists num_city_list= num_list+ city_list The addition of two lists can be performed using the + operator. If you want to find the index value of an item in lists provided the item in know, this can be done as shown below print(city_list.index('Chennai',0,3)) Index range represents the portion of the list that you want to extract as shown in the below example print(city_list) Negative index references the list from the last value, in this case, it is Coimbatore Index Range We also have a negative index number as shown below print(city_list)
