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之间
发布于 2014-03-13 02:45:22
在此代码中,您从未显式调用函数check。
https://stackoverflow.com/questions/22360985
复制相似问题