Currently doing the python II guided project,
I want to design a function that allows me to pull categories into a list, and within that list automatically create dictionaries. ie.
categories = [‘art’, ‘game’, ‘family’]
then
art = { }
game = {}
family = {}
instead of creating these dictionary manually.
I don’t think it’s considered good programming practice to convert strings into variable names to then store dictionaries.
There are ways to do this - Convert string to variable name in python - Stack Overflow
But, I would recommend that you instead create a dictionary of dictionaries such that "art", "game"
etc are keys and their corresponding values are empty dictionaries. I think that’s a better approach.
okay! thank you for your response as always : )