+ 1
How can I add a new key to multiple dictionaries at once?
Suppose that I have several dictionaries, each holding some data about clients of a gym. (one dictionary store ages, the other stores weight, and so on). How can I insert a new client in all dictionaries in a single move?
1 Odpowiedź
0
You can store the dictionaries in a big dictionarie, then create a function that adds that key for each dictionarie with a for bucle.
If you let me give you other way to do it, if you know classes you could create a Person Class that stores all that values, then you can make a dictionarie with the person's name as the key and Person Class as the value :)