Introduction
List basics
6. Assigning new values to list elements
Lists with if statements and loops
Lists in functions
Summary

Instruction

Good. Using square brackets, we can also assign new values to specific list elements.

# define a list
companies = ['Royal Dutch Shell', 'BP', 'Total', 'Volkswagen', 'Glencore Xstrata', 'Gazprom']

# ranking changes
companies[5] = 'E.ON'

We found out that E.ON now has a higher revenue than Gazprom, so we change the sixth element (remember, its index is 5) to E.ON. Gazprom is out of the game!

Exercise

Correct the mistake in your data. The third day's water level should be 693. Print the contents of the changed list.

Stuck? Here's a hint!

The third day has an index of 2.