Advertisement
OrFeAsGr

print stuff and then erase them

Jul 12th, 2023
1,165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. from time import sleep
  2.  
  3. print_count = 0
  4.  
  5. def myprint(stuff, erase=0):
  6.     global print_count
  7.     print(stuff)
  8.     print_count += 1
  9.     if erase == 1:
  10.         for i in range(0,print_count):
  11.             print("\033[F",  end="")
  12.             print("\033[K", end="")
  13.  
  14. myprint("Some stuff printed bla bla bla")
  15. myprint("Some other stuff printed")
  16. myprint("now we're gonna delete these 3 lines")
  17. sleep(1)
  18. myprint("", 1)
  19. myprint("Ok so now we're printing some stuff and you input something below:")
  20. yours = input()
  21. myprint("Ah, yes... " + yours + " indded.")
  22. myprint("Now time to erase all this...")
  23. sleep(1)
  24. myprint("", 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement