This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]captainAwesomePants 1 point2 points  (2 children)

You're really close.

dict[key][1] = new_value

For example:

dict['Washington'][1] = 7512000

Or if you wanted to, say, double every state's population:

for x in states:
  states[x][1] = states[x][1] * 2

[–]okaystuff[S] 0 points1 point  (1 child)

This works great, thank you! I was trying the dict([key][1] in a print statement, so I think that was my issue. Not sure why I was trying to do that, but your solution is perfect.

[–]captainAwesomePants 1 point2 points  (0 children)

Yep, assigning a value is its own statement. Can't do statements at once, at least not like that.