in one of my master degree classes I have to create in python a sudoku game (with special rules). My professor request is that I need to import a .txt file with the sudoku board (for me created) to my code file.
I do like this: **
def import_boardsudoku(filename):
file=open(filename,'r')
content=file.read()
file.close()
return content
hs = []
for line in content:
hs_line = line.replace("\n"," ").split(",")
hs.append(hs_line)
for i in range(len(hs)):
for j in range(len(hs[i])):
if hs[i][j] == "0":
hs[i][j] = " "
else:
hs[i][j]=int(hs[i][j])
return hs
print import_boardsudoku("sudoku_hs.txt")
**
But I don´t understand:
Inside my .txt file its:
Thank you very much for your help! :)
everything below
return content
is unusable as you are returning early.