log.txt at the start.
class Log:
def __init__(self, path):
self.path = path
def add(self, text):
with open(self.path, "a") as f:
f.write(text + "\n")
def lines(self):
with open(self.path) as f:
return f.read().split("\n")
log = Log("log.txt")
log.add("start")
log.add("stop")
print(log.lines())
What does the program print?Log in to join the discussion.
Loading…