Updating lists

You can update elements of lists, as shown in the following code:

#!/usr/bin/python3
cities = ['Mumbai', 'Bangalore', 'Chennai', 'Pune']
print ("Original Value: ", cities[3])
cities[3] = 'Delhi'
print ("New value: ", cities[3])


Output:
Original Value: Pune
New value: Delhi
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset