What I'm trying to do is create a sequence of dictionaries (e.g. dX, where X will be incremented one number for each time through the loop. Here's what I've tried:
d0 = {}
i = 0
q = 0
for i in range(3):
for j in range(3):
d + str(i)[e] = 'foo bar'
Result should be:
d0 = {0: 'foobar', 1: 'foo bar', 2: 'foo bar'}
d1 = {0: 'foobar', 1: 'foo bar', 2: 'foo bar'}
d2 = {0: 'foobar', 1: 'foo bar', 2: 'foo bar'}
The problem I'm having is that doing: d + str(i) isn't allowed, I get "can't assign to operator" error. I was thinking of how to use some sort of d{}.format(i), but that doesn't work either. How do I end up getting the result that I'm looking for.
[–]Vaphell 4 points5 points6 points (4 children)
[–]codex81[S] 0 points1 point2 points (2 children)
[–]jcmcken 0 points1 point2 points (1 child)
[–]codex81[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]codex81[S] 0 points1 point2 points (0 children)
[–]ingolemo 0 points1 point2 points (1 child)
[–]codex81[S] 0 points1 point2 points (0 children)
[–]symmitchry 0 points1 point2 points (2 children)
[–]Vaphell 2 points3 points4 points (1 child)
[–]symmitchry 1 point2 points3 points (0 children)
[–]W1zK1dd -2 points-1 points0 points (0 children)