Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def add_to_file(path: str, text: str) -> str:
- with open(path, 'w+') as f:
- for index, char in enumerate(text):
- if f.tell() < 100:
- f.write(char)
- if f.tell() >= 100:
- f.seek(f.tell() - 1, 0)
- f.truncate()
- return text[index:]
- return ''
Add Comment
Please, Sign In to add comment