DEV Community

rababR1
rababR1

Posted on

Answer: How can I have a user save and load their game in my text-based rpg in Visual Studio Code?

Here is the solution I came up with:

def save(what_to_write):
  file = open("file_name.txt", "w")
  write = file.writelines(what_to_write)
  file.close()

  file = open("file_name.txt")
  cont = file.readline()
  print (cont)
  file.close()

Top comments (1)

Collapse
 
rababr1 profile image
rababR1

A pretty good answer I found