I have 8 dictionaries intialized in the same way
dicc_1={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
dicc_2={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
dicc_3={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
dicc_4={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
dicc_5={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
dicc_6={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
dicc_7={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
dicc_8={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0}
Question1: Is there a better way to do this? Because if I need more dictionaries it will make the script very large It would be nice if there is a solution like this:
dicc_1,dicc_2,dicc_3,dicc_4,dicc_5,dicc_6,dicc_7,dicc_8={"Area":0,"Age":0,"Weight":0, "Height":0, "All":0} * 8
But it doesn't work
Question 2: Is there a way to change the keys if I pass a list of keys? Like this function that doesn't work too
def myFunc(ListOfKeys):
dicc_1,dicc_2,dicc_3,dicc_4,dicc_5,dicc_6,dicc_7,dicc_8={ListOfKeys[0]:0,ListOfKeys[1]:0,ListOfKeys[2]:0, ListOfKeys[3]:0, ListOfKeys[4]:0} * 8
"Do stuff with dictionaries"
"Return all dictionaries"
So this evaluation:
myFunc(ListOfKeys=["Area","Age","Weight","Height","All"])
Would intialize dictionaries in this way:
dicc_1={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
dicc_2={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
dicc_3={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
dicc_4={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
dicc_5={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
dicc_6={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
dicc_7={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
dicc_8={"Area":0,"Age":0,"Weight":0,"Height":0,"All":0}
And this evaluation:
myFunc(ListOfKeys=["Car","Train","Ship"])
Would intialize dictionaries in this way:
dicc_1={"Car":0,"Train":0,"Ship":0}
dicc_2={"Car":0,"Train":0,"Ship":0}
dicc_3={"Car":0,"Train":0,"Ship":0}
dicc_4={"Car":0,"Train":0,"Ship":0}
dicc_5={"Car":0,"Train":0,"Ship":0}
dicc_6={"Car":0,"Train":0,"Ship":0}
dicc_7={"Car":0,"Train":0,"Ship":0}
dicc_8={"Car":0,"Train":0,"Ship":0}