How to change sub keys in a dictionary at the same time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By playsord95

I have a dictionary of weapons, with 15 in total at the moment.

Long story short - I want to press a button that will increase the max durability of all weapons by 10%. I assume there is a better way of doing this than my current way of typing

global.melee[1][max_durability] += melee[1][max_durability] * 1.1

for every single weapon, I mean it obviously works but is there a more efficient way of doing this?

dictionary looks like this;

var melee {
1: {
"name" : "baseball bat",
"damage" : 4,
"current_durability" : 50,
"max_durability" : 50

i know there is code like “for i in” … etc, but im fairly new to coding and cant quite figure it out. Any help would be great, Thanks :smiley:

:bust_in_silhouette: Reply From: rakkarage
for key in melee:
    melee[key].max_durability *= 1.1

Thanks so much!
I was so close but yet so far

playsord95 | 2020-08-14 17:59