sudoku[i][j] is returning 9 and your test array is acessible with a number between 0 and 8 (9 elements). The problem is that you want to do test[9] and you can only go to test[8]
Comment has been collapsed.
181 Comments - Last post 2 minutes ago by hunggar28
1,046 Comments - Last post 10 minutes ago by Lep9six
1 Comments - Last post 40 minutes ago by hawkeye116477
0 Comments - Created 1 hour ago by Chris76de
2,276 Comments - Last post 1 hour ago by MeguminShiro
46 Comments - Last post 3 hours ago by Inkyyy
25 Comments - Last post 3 hours ago by ewoda
51 Comments - Last post 2 minutes ago by hieeeen
775 Comments - Last post 2 minutes ago by thejaff72
30 Comments - Last post 15 minutes ago by Skwerm
20 Comments - Last post 20 minutes ago by wigglenose
0 Comments - Created 21 minutes ago by wigglenose
17,312 Comments - Last post 21 minutes ago by Carenard
16,343 Comments - Last post 22 minutes ago by Carenard
Hi, yeah i know this isn't place for this, but i'm not sure where else i could post it so i might as well give it a shot.
i'm writing a python code that checks if sudoku is solved correctly, and i have problems at the very start. I have this so far
def testsudoku(sudoku):
sudoku=[[2,9,5,3,1,6,8,4,7], [3,4,8,7,9,2,6,1,5], [6,7,1,5,4,8,9,2,3], [5,6,3,2,8,9,1,7,4], [1,8,7,6,3,4,2,5,9], [4,2,9,1,5,7,3,6,8], [7,3,6,8,2,5,4,9,1], [8,5,4,9,6,1,7,3,2], [9,1,2,4,7,3,5,8,6]]
testsudoku(sudoku)
I get an error in line test[sudoku[i][j]]+=1 saying IndexError: list index out of range. If i write the same thing with numbers and not i and j it works fine and since range(9) returns numbers from 0 to 8 it should also be ok. I'm not quite sure what the problem is but i'd appreciate help.
Comment has been collapsed.