I know my title may be somewhat confusing, but I had trouble describing my issue. Basically, I need to create a bunch of variables that all equal 0, and I want to do this with a for loop so I don't have to hard code it.
The problem is each variable needs to have a different name and when I call the number from my for loop to create the variable, it doesn't recognize that I want the number from the for loop. Here is some code so that makes more sense:
total_squares = 8
box_list = []
for q in range(total_squares):
box_q = 0
box_list.append(box_q)
I need it to create box_1 and add that to the list, then create box_2, and add that to the list. Just it thinks I'm calling a variable box_q, rather than calling the number in the for loop.
box_list[box[3]]globals()dictionary for this (it doesn't work for function local variables). Anyway, using a list or dict directly would be much better, as @Selcuk already said.