im trying to generate a Sudoku. I tought about using an Array for this. Following is how i create the array: (ignore the fact that these are not correct Sudoku numbers...)
row_array = [[1, 99],[2],[3], [4], [5], [6], [7], [8], [9]]
It does work fine. The problem is with an if Statement. If i do:
print(row_array[0][1])
or:
r = 1
print(row_array[0][r])
to get the "99" it does work fine! But if i use this variable method in an if statement like this:
if y not in row_array[1] and y not in row_array[0][r]:
row_array[1].append(y)
i get the following ERROR:
TypeError: argument of type 'int' is not iterable
I had the Sudoku working, but it took to much code, so i want to set up a counter to replace the rows and collums with an it. Im aware of you guys probably already having a much better code for a sudoku, but i wanna learn myself, and make the code better and shorter over time. I dont learn to code real good, by just copy someone elses idea or way to code.
Aucun commentaire:
Enregistrer un commentaire