KC358287

Untitled

Jan 25th, 2021 (edited)
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data