I have three lists inside a list. I want to change a specific element of a specific list. So lets say the second list, first element. I tried it like this:
Here is the whole thing, I am just learning how to program so don't judge me :)
class Board:
#creates visible playing board
global rows
rows = []
def create_row(self):
row1 = []
while len(row1) <= 4:
if len(row1) <= 3:
row1.append("x")
else:
row1.append("\n")
rows.append(row1)
def input(self):
print "Enter a colum num"
height = int(raw_input(">"))
height = height - 1
print "Enter a row num"
width = raw_input(">")
print rows.__class__
# for i in rows[height]:
# i[height] = 'a'
def display(self):
for i in rows:
for m in i:
print m,
row1 = Board()
row1.create_row()
row2 = Board()
row2.create_row()
row3 = Board()
row3.create_row()
row4 = Board()
row4.create_row()
row4.display()
row4.input()
row4.display()
rowsis unlikely to be the problem. @bipolarpants, please show the whole traceback, which should confirm that the error is in the linei[height] = 'a'. Before that line, insertprint type(i), repr(i)and show us what the result is.