1

I'm trying to print the name as hyphens with time delay of 0.1 second so it looks like kind of animation moving. I want the output that is the words to get displayed in horizontal manner but im getting it in vertical manner. Please check the below code and suggest how to move the cursor to the start position. code:

import time
import sys
name='superstar'
word={'s':'''
 _
|_
 _|''',
'u':'''
| |
|_|''',
'p':'''
 _
|_|
|''',
'e':''' 
 _
|_
|_''',
'r':'''
 _
|_|
|\\''',
't':'''
___
 |
 |''',
'a':''' 
  _
 /_\\
/   \\'''}

for i in name:
    for j in word[i]:
        print(j, end='')
        sys.stdout.flush()
        time.sleep(0.1)

My output is as below: _ |_ | | | || _ || | _ | |_ _ || |
_ |
_|


| | _ /
/
_ |
| |\

But I want O/p as below:

*SUPERSTAR (need it in horizontally)

dinesh kumar
  • 95
  • 1
  • 4

1 Answers1

1

One character of your output spans already across three lines. So you would need to go up 3 lines (maybe even 4) after printing each character (see here) and in addition to the right. For this you need some control keys (ANSI controlsequence) and terminals which accept those keys.

Alternatively you could use some packages like: ART or PYFIGLET But I don't know if they support animations.

chiefenne
  • 565
  • 2
  • 15
  • 30