Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction to nested lists
Iterating over nested lists
Modifying nested lists
10. Modifying elements
Working with multiple lists


Great! Now, let's move on to find out how we can modify nested lists.

Because we want to modify the elements, we need to iterate over indexes again. Indexing over values won't work. Look at the example below, where we convert donation amount totals from U.S. dollars to euros:

donations = [
  [345.0, 287.80, 119.27, 329.30],
  [294.25, 349.0, 178.90, 262.34],
  [401.0, 456.45, 289.43, 319.27]

for i in range(len(donations)):
  for j in range(len(donations[i])):
    donations[i][j] *= 0.88

Here we multiply each element in the nested lists by 0.88 (the conversion rate from USD to EUR).


You are given hackathon_teams nested list that contains only team names. We now need to modify this list to store an abbreviated name for each team. Let's shorten each team name to its first five letters and add a dot (.).

For instance: 'HackKittens' should become 'HackK.'

Stuck? Here's a hint!

To get the first five characters, use the following code: