I have some vars and its values:
var1, var2, var3, var4 = 9, 8, 7, 6
I have dict:
map = {
1: 'var1',
2: 'var2',
3: 'var3',
4: 'var4',
}
I have some calculations and get number:
key = 2 # 1/3/4
Can I somehow change var (ex. var2) by addressing to it something like map[key] += 10
so print(var2)
shows 18?
Ok. Real code:
deleted, invalid, no_item, no_game, generic, no_dnvt, vt_null, unknown = 0,0,0,0,0,0,0,0
# some code ...
if result < 0:
deleted += 1
if result == -1: # invalid file (no root)
invalid += 1
elif result == -2: # invalid file (no GameObjects node)
invalid += 1
elif result == -3: # not an "Item" type
no_item += 1
elif result == -4: # attribute "HasGameplayValue" is False
no_game += 1
elif result == -5: # Stats points to a generic/immutable object
generic += 1
elif result == -6: # no DisplayName or VisualTemplate
no_dnvt += 1
elif result == -7: # VisualTemplate with no value
vt_null += 1
elif result == -8: # DisplayName with unknown handle
unknown += 1
# some code ...
continue
So we have exactly same action (+= 1) but with different vars. I want to make this code shorter and clearer. And w/o "match case" or bunch of ifs.