0
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和9Python Sudoku拼圖9 x 9 Checker
我懷疑除此之外還有更多。 infile應該可能是網格。還有一些其他的東西。 – Chris