Basically, I'm editing a battleship code so that you can save the board at any point in the game by writing it to a file. However, when I write it to the file, the only thing that is in the file is the word "None". These are the two chunks I've added.
def save_game():
with open('savegame.txt', 'w') as f:
f.write(str(print_board(board, True)))
. . . .
finally:
if str(position) == 'save':
save_game()
return print_board(board, reveal = False)
exit()