How would you create a dictionary in python, which would look a bit like this:
{1:0, 2:0, 3:0, 4:0, ...}
for a specific number of iterations?
How would you create a dictionary in python, which would look a bit like this:
{1:0, 2:0, 3:0, 4:0, ...}
for a specific number of iterations?
Use dict.fromkeys()
>>> dict.fromkeys(range(1, 5), 0)
{1: 0, 2: 0, 3: 0, 4: 0}
You could do this:
dict(enumerate([0]*10,1))
{1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0}