Python Sudoku Puzzle 9 x 9 Checker

时间:2014-03-12 18:43:13

标签: python

while True:
    try:
        file = input("Enter a filename: ") 
        fi = open(file, "r")
        infile = fi.read()
        grid = [list (i) for i in infile.split()] #Puts the sudoku puzzle into a list in     order to check that the total number is valid
        check = len(grid)
        print("The total number in this puzzle is:",check) #Counts the amount of numbers in the sudoku puzzle
        break
    except FileNotFoundError:
        print ("The inputted file does not exist")

def check(infile):
    count = 0
    for j in range (0,9):
        for n in range(0,9):
            if infile[j].count(infile[j][n]) <= 1:
                count = count + 0
            else:
                count = count + 1

这是我目前的数独检查代码,有人请告诉我它有什么问题,因为我试图找出列中的所有数字是否在1到9之间

1 个答案:

答案 0 :(得分:1)

您从未在此代码中明确调用函数check