I have a series of lists with two items in each of them called box1, box2, box3, etc. and am trying to append to a master list to access later. Below is what I thought would work, but it is not. I think it may be something with the string in the append
method adding to i
, but I am not sure.
This is obviously only adding the string box + i
, but I need to figure out a way to loop through and add all similarly named items to this list. What is the best way to accomplish this goal?
box1 = [1,2]
box2 = [3,4]
boxes = []
##Adding strings. I need to add box items instead.
for i in range(11):
boxes.append("box" + str(i))
I want to see this:
boxes = [[1,2],[3,4]]
FYI: I cannot use imported libraries for this due to the software I am limited to using.