I am wanting to print a matrix grid which is derived from a list of lists. The grid should look as follows:
Col 0 Col 1 Col 2
Row 0 1 2 3
Row 1 4 5 6
Row 2 7 8 9
However, I can't figure out how to print the lists without the [ ] around them. My code so far is as shown:
lol = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for i in range(0,len(lol )):
print " "*5 +"Col", i,
print "\n"
for i in range(0,len(lol )):
print "Row",i,lol[i]
Any suggestions or advice would be greatly appreciated. Thanks!
Col 0 Col 1 Col 2
Row 0 1 2 3
Row 1 4 5 6
Row 2 7 8 9
However, I can't figure out how to print the lists without the [ ] around them. My code so far is as shown:
lol = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for i in range(0,len(lol )):
print " "*5 +"Col", i,
print "\n"
for i in range(0,len(lol )):
print "Row",i,lol[i]
Any suggestions or advice would be greatly appreciated. Thanks!
Comment