Trying to simplify lots of repetitive reading and writing in a script of mine, and I can not figure out how to get data out of def readfile.
def
return statement at the end of a function to return variables (readvar in this case) (and you almost always should).readvar) to a new variable (e.g. rv).def writefile(FILE, DATA):
file = open(FILE, "w")
X = str(DATA)
file.write(X)
file.close()
def readfile(FILE):
file = open(FILE, "r")
readvar = file.read()
file.close()
return readvar
rv = readfile("BAL.txt")
print(rv)