0

I am trying to make code that displays text, goes back to the beginning of the chunk of text and displays something different.

def melee_attack():
    melee1 = ('''      /| ________________
O|===|* >________________>
  \|''')
    melee2 = ('''_   _   _   _   /| ________________
_   _   _ O|===|* >________________>
_   _   _   _   \|''')

    print(melee1)
    time.sleep(1)
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    print(melee2)
    time.sleep(1)
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    sys.stdout.write("\033[F")
    print(melee1)
    time.sleep(.8)

This works for animating a bow and shield but for some reason for the sword it prints [?][F instead of going up a line. The other times I used this are just copied and pasted from this so I know I didn't type it differently, it just doesn't work this one time.

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
Dulnefni
  • 9
  • 2
  • Possible duplicate of [Replace console output in Python](https://stackoverflow.com/questions/6169217/replace-console-output-in-python) – Green Cloak Guy May 18 '19 at 04:35
  • Where it should print underscores it just prints [?][F, is this a glitch with escape codes not being accepted by python or is something wrong with how I set the escape code up? – Dulnefni May 18 '19 at 16:42

0 Answers0