def clearclip(text=""): ''' Clear the clipboard if nothing has been copied since data was added to it ''' if text == "": pyperclip.copy("") elif pyperclip.paste() == text: pyperclip.copy("")