01 / 07
One trip outside your program
Take some text out of a variable, put it into a file, and bring it back into a variable.
It is a small thing, but you have just made one trip outside your program. An ordinary variable disappears the moment the run ends; what you put in a file stays. That difference is the decisive one.
memo = "buy milk"with open("memo.txt", "w") as f: f.write(memo)with open("memo.txt") as f: loaded = f.read()print(loaded)Result
buy milk