Ask coding questions

← Back to all posts
Python Animation Help
Brendan23 (166)

Hello, If you run the repl it works but the same line at the top of the console doesn't change! how can I change or remove that?
also, if you can, how can I remove the delay between each loop of the for i in range(4) loop?

Comments
hotnewtop
InvisibleOne (3228)

Just delete line 11 to remove the time it waits.

Brendan23 (166)

@InvisibleOne Oh, I'm sorry, I mean, when you run the repl, it will go one loop with correct sleep time, then it will wait longer than the correct, then go back to the correct.
If it is confusing I will explain it better.

MrVoo (95)

To remove/shorten the delay, edit line 11. Also I would suggest redoing it entirely and have something like this:

from sys import stdout
from random import randint
from time import sleep
while True:
  print('|'+' '*randint(1,30), end='')
  stdout.flush()
  sleep(0.005)
Brendan23 (166)

@MrVoo hmmm... ok, let me try that.

Brendan23 (166)

@MrVoo It doesn't really look real. it looks like the rain is going backwards/up.

MrVoo (95)

@Brendan23 Increase the delay maybe? It looks normal for me, but maybe I'm laggy :>

MrVoo (95)

@Brendan23 Also, try adding print('\033[38;2;0;255;255m') right before the while true loop :)

Brendan23 (166)

@MrVoo Ok, but if you run it, it goes up not down:

|               |             | 
      |              | 
   |         |           |      
          |             |       
       |            |     
  |                     | 
            |          

if you start at the top, then scroll down, that's what it looks like, it looks like the rain is going up/↑

MrVoo (95)

@Brendan23 Hmmm true, maybe use your old method