I'm trying to create a connect 4 class, but whenever I drop a letter/token, it updates the entire column. I can't figure out for the life of me why this is happening:
class ConnectFour():
def __init__(self, width, height):
self.width = width
self.height = height
self.board = [[0] * width] * height
def dropLetter(self, letter, col):
count = self.height - 1
while count > 0 and self.board[count][col] != 0:
count -= 1
print self.board[count][col]
self.board[count][col] = letter
print self.board
C = ConnectFour(4,4)
C.dropLetter('X', 0)
Then when I print self.board, every slot in the provided column is updating. Why is this happening?