I'm working on a sudoku solver and I have this board:
board = [
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
]
And let's say I now want to just change every number to a random one (between 1 and 9). I tried this:
for lst in board:
for num in lst:
num = random.randint(1, 9)
I think this just takes the zeros and changes them to the random numbers but doesn't write them back into the list, because when I print the list it's still just zeroes. So how do I make it to actually write the random numbers back into the board?
Sorry for the basic question, I'm new. I tried looking it up but I just don't seem to understand for loops correctly...