turn for in loops local variables into mutable variables

You can make city mutable by adding var to its declaration:

for (country, var city) in countries {

Unfortunately, changing it won't affect your countries Dictionary, because you're getting a copy of each sub-Dictionary. To do what you want, you'll need to loop through the keys of countries and change things from there:

for country in countries.keys {
    if countries[country]!["London"] != nil {
       countries[country]!["London"]! = "Picadilly Circus"
    }
}

Tags:

Swift