[英]Python Sudoku Puzzle 9 x 9 Checker
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
This is my current code for a sudoku checker, will someone please tell me what is wrong with it, because I am trying to find out if all the numbers in the columns are between 1 and 9 这是我当前的数独检查程序代码,有人可以告诉我这是什么问题吗,因为我试图找出列中的所有数字是否都在1到9之间
您永远不会在此代码中显式调用函数check
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.