0
number_side1_list=[]
number_side2_list=[]
number_side3_list=[]
number_side4_list=[]
for i in range(1,19):
    w="number_side1_"+str(i)
    w1="number_side2_"+str(i)
    w2="number_side3_"+str(i)
    w3="number_side4_"+str(i)

    number_side1_list.append(w)
    number_side2_list.append(w1)
    number_side3_list.append(w2)
    number_side4_list.append(w3)

print("")
print(number_side1_list)
print("")
print(number_side2_list)
print("")
print(number_side3_list)
print("")
print(number_side4_list)

So my code makes a list 18 strings but I would like to make them into variables. I want to be able to use them for a different part of my program as an array.

My desired out is as follows:

((number_side1_1 ,number_side1_2 ,number_side1_3 ....)

Edit: So I am making a monopoly game and I need to make 2 buttons for every tile. So there will be 18. Each button will increase in by 1 when I click it. So I need a way to store 4 variables. The x,y of where it is positioned and the number, and the surface to which it needs to blink to. I'm still really new to programming so I'd appreciate some advice as to how I might do that. I made a a lot of tiny rectangles for the button which are now clickable. The i devided the x and y coordinates by 2 of each rectangle for the position. Next I was going to store them in an array like this (x,y,n,surface) for each square. I already have the x and y for each rectangle I just needed the n and surface. I'll look into dictionaries and see how they work.

Juan Ramos
  • 179
  • 1
  • 10
  • You want a dictionary instead, not variables in the namespace – roganjosh Mar 26 '19 at 21:49
  • Why are you creating 4 lists? As @roganjosh says, it sounds like you want a single map with18 things in it. But I'm still confused as to what you really want to store in the map. – CryptoFool Mar 26 '19 at 21:55
  • Your code seems to print almost what you want, except 4 times. What do you want different than what you're doing now? Do you want the 4 lists to themselves all be in one list? – CryptoFool Mar 26 '19 at 22:00
  • Its one for each side of the game board – Juan Ramos Mar 26 '19 at 22:16

0 Answers0