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.
13 Comments - Last post 55 seconds ago by MSKOTOR
47,148 Comments - Last post 20 minutes ago by FranckCastle
367 Comments - Last post 25 minutes ago by dailylhama
166 Comments - Last post 50 minutes ago by paco7533
814 Comments - Last post 1 hour ago by WeakSweet
5 Comments - Last post 4 hours ago by Steamgifty
19 Comments - Last post 7 hours ago by juryman00
12 Comments - Last post 5 minutes ago by AlexSaysSG
37 Comments - Last post 8 minutes ago by RenRenIsWeird
70 Comments - Last post 12 minutes ago by MSKOTOR
239 Comments - Last post 16 minutes ago by MpoMp
199 Comments - Last post 25 minutes ago by Lugum
2,532 Comments - Last post 25 minutes ago by Lyselfia
87 Comments - Last post 1 hour ago by Formidolosus
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.