I have two dictionaries in a program I'm writing for fun to get practice dealing with .jsons in Python. I want my program to take any player's .json file (actually pretty easy to obtain) and output how many runes of each rune type the player owns. It's basically my first week of learning about data in Python (or any language) so I'm still very new to this.
The first dictionary, I created like this:
rune_set_counts = {}
for i in range(1, 24):
rune_set_counts[i] = 0
I made the range begin with 1 because the game's .json indexes rune sets using values from 1 to 23.
The second dictionary contains 23 keys, and each key is the string that is the actual name of that particular rune type in the game. So, for example, in rune_set_counts, the first key is 1. In my second dictionary, rune_set_translated_counts, the first key is the corresponding name, "Energy".
I would like to make a function that transposes the values from the first dictionary to the second dictionary. If rune_set_counts[1] = 5, I want rune_set_translated_counts[Energy] = 5.
This was my attempt at a function:
def convert_to_rune_set(old_dict, new_dict):
for i in range(len(old_dict)):
frequency = old_dict[i+1]
new_dict[i] = frequency
The problem is, I tried that and it just added all 23 key-value pairs from the old dictionary to the new one, lol. I don't want 46 keys. How should I do this?