I want to replace items in lists of lists to draw a cross. So for example the list:
x="X"
lista =[[x," "," "," ",x],[" ",x," ",x, " "],[" "," ",x," "," "],[" ",x,"
",x, " "],[x," "," "," ",x]]
for l in lista:
print (" ".join(l))
results in:
X X
X X
X
X X
X X
But I can not successfully replace the items
in an order list " size
", as shown in the following code:
size =int(input("Which is the size of the nested lists? "))
col=[]
for x in range (size):
col .append(str(x))
tablero =[]
for b in range(size):
tablero.append(col)
for row in range(len(tablero)):
for col in range(len(tablero)):
if col == row:
tablero[col][row]= "X"
for l in tablero:
print (" ".join(l))