def create_board(): b = [[['',''] for i in range(8)] for j in range(8)] return b game_board = create_board() for i in game_board[0]: for idx, val in enumerate(i[1::2]): idx[0] = 0 idx[1] = 0 print game_board
I have this script in which I need to iterate over the first list, which is in the game_board list. Starting from the second item, I need to change the values ββin each list of other items. However, when I run this, I am greeted by an error
idx[0] = 0 TypeError: 'int' object does not support item assignment
It would be understandable if IDLE complained that I was assigning the str variable (which would be a problem with iterating over the values, not the indexes), but I don't understand why this problem is happening, given that I don't have integers.
source share