I want to display this series for experimentation.
A
B
AA
BB
AAA
BBB
without adding new line like it works fine with 'A' only. This is code for A only and it works.
root@kali-linux:/tmp# cat a.py
import time
x = "A"
while True:
print(x, end = "\r")
x += "A"
time.sleep(1)
Now I added B.
root@kali-linux:/tmp# cat a.py
import time
x = "A"
y = "B"
while True:
print(x, end = "\r")
print(y, end = "\r")
x += "A"
y += "B"
time.sleep(1)
Unfortunately B eats the A and only B increases. I tried sth like this but it causes repetition which i dont want
import time
x = "A"
y = "B"
while True:
print(x, end = "\r")
print('\n', end='\r')
print(y, end = "\r")
x += "A"
y += "B"
time.sleep(1)
Is there any way to print the series without repetition? I got this as answer but seems hard to implement in python3.
\r moves back to the beginning of the line, it doesn't move to a new line (for that you need \n). When you have 'A' and 'B' it writes all the 'A's and then overwrites it with the 'B's.
You would need to loop through all the 'A's, then print a new line \n, then loop for the 'B's.
Edit
Both curses and coloroma answer were OK but curses causes terminal to die when try except and it was slightly inconfigurable. Coloroma was easiest and the answer which I needed.