# tennis loading screen by snowyuwuwu :)
import os
import time
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
clear()
animation = [
"o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
" o",
"o"
]
while(True):
for x in animation:
clear()
print(x)
time.sleep(.2)
#๐ Code reviews needed :>
37 messages ยท Page 1 of 1 (latest)
@woven hazel
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
any code suggestions or reviews? 0/10
There isn't a ton here to review, so there's not much to say.
You can generate animation to make it cleaner and adjustable:
!e
animation = [(' ' * n) + 'O' for n in range(10)]
animation += reversed(animation)
print(*animation, sep='\n')
Oops
id recommend to use ansi sequences instead of guessing the clear command based on the os
and you could use a loop and multiply space by a counter instead of hardcoding the animation list i guess, ^
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | O
002 | O
003 | O
004 | O
005 | O
006 | O
007 | O
008 | O
009 | O
010 | O
011 | O
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/PRAUSMAUYEZBS44ZRFWVKHA3MA
One moment
printing "\x1B[2J" should do what cls/clear does but "cross-platform", the \x1B is like, a special byte thats used as the start for a bunch of "commands" like that
You can also use itertools.cycle to make an infinitely long, repeating animation.
!e
tennis loading screen by snowyuwuwu ๐
import os
import time
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
clear()
animation = [(' ' * n) + 'O' for n in range(10)]
animation += reversed(animation)
while(True):
for x in animation:
clear()
print(*animation, sep='\n')
time.sleep(.2)
oops
:x: Your 3.12 eval job timed out or ran out of memory.
001 | O
002 | O
003 | O
004 | O
005 | O
006 | O
007 | O
008 | O
009 | O
010 | O
011 | O
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/O66LOUPFWP2ANYRZ4F2RNGYN5E
I didn't expect that output
(ran out of memory because the buffer it prints (writes) to is well, memory)
print(*animation, sep='\n') was just to display the example here.
# tennis loading screen by snowyuwuwu :)
import os
import time
def clear():
os.system('cls' if os.name == 'nt' else 'clear')
clear()
animation = [(' ' * n) + 'O' for n in range(10)]
animation += reversed(animation)
while(True):
for x in animation:
clear()
print(*animation, sep='\n')
time.sleep(.2)```
It is not doing the animation
You'd use the animation exactly l;ike you did before.
it is just cleaning the console and printing this
001 | O
002 | O
003 | O
004 | O
005 | O
006 | O
007 | O
008 | O
009 | O
010 | O
011 | O
print(*animation) "unpacks" the list in the animation and puts each item as like, a positional argument
e.g. print(*[1, 2]) == print(1, 2)
Don't change the loop. Keep what you had before.
Also, it would need to be adjusted slightly to avoid the double max line maybe:
max_n = 10
animation = [(' ' * n) + 'O' for n in range(max_n)]
animation = animation + [(' ' * max_n) + 'O'] + animation[::-1]
The main benefoit to this is you can adjust the width to match something like the screen size, and you don't need to hard-code every possiblity in the code.
i'd say u dont necessarily need to make a generator for the animation
just writing it as you did at the first place is fine
well it all depends i guess on how long the code gets
your code is pretty short so u can make it very abstract i suppose
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.