Let’s say I have 3 empty dictionaries:
dic1 = {}
dic2 = {}
dic3 = {}
And I want to add to these dictionaries all at once, using a function. What is the simplest way to do this, so far I have:
def fillDics(x):
count = 0
for i in range(0, x):
if count==0:
dic1[legendaryfn[count]] = 0
dic1[legendary[count]] = 1
count+=1
if count==1:
dic2[legendaryfn[count]] = 0
dic2[legendary[count]] = 1
count+=1
Et cetera, this seems hugely inefficient. What am I missing? I’m pretty new to programming so I’d appreciate any help you can offer.
That’s accomplished like this.
Additionally, if the numeric values are meaningful to you you can add enumerate:
Or what have you.