Reputation: 181
Say I want to create a new list every (in a loop) time the variable i (an integer) changes, eg:
game_1 = []
game_2 = []
game_3 = []
...
game_i = []
How would I do this?
I've tried putting game_i
, which obviously doesn't work; neither does game[i]
,
Upvotes: 1
Views: 63
Reputation: 353
gb = globals()
for i in range(10):
gb['game_{0}'.format(i)] = []
Upvotes: 2