KC358287

Untitled

Jan 25th, 2021 (edited)
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def add_to_file(path: str, text: str) -> str:
  2.     with open(path, 'w+') as f:
  3.         for index, char in enumerate(text):
  4.  
  5.             if f.tell() < 100:
  6.                 f.write(char)
  7.  
  8.             if f.tell() >= 100:
  9.                 f.seek(f.tell() - 1, 0)
  10.                 f.truncate()
  11.  
  12.                 return text[index:]
  13.     return ''
  14.  
Add Comment
Please, Sign In to add comment