#๐Ÿ”’ Code reviews needed :>

37 messages ยท Page 1 of 1 (latest)

woven hazel
#
# 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)
high talonBOT
#

@woven hazel

Python help channel opened

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.

woven hazel
#

any code suggestions or reviews? 0/10

arctic crypt
#

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

untold citrus
#

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, ^

woven hazel
#

Ohh

#

Should I make a code using those tips?

high talonBOT
woven hazel
#

One moment

untold citrus
arctic crypt
#

You can also use itertools.cycle to make an infinitely long, repeating animation.

woven hazel
#

!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

high talonBOT
woven hazel
#

I didn't expect that output

untold citrus
#

(ran out of memory because the buffer it prints (writes) to is well, memory)

arctic crypt
#

print(*animation, sep='\n') was just to display the example here.

woven hazel
#
# 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

arctic crypt
#

You'd use the animation exactly l;ike you did before.

woven hazel
#

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
untold citrus
#

e.g. print(*[1, 2]) == print(1, 2)

arctic crypt
#

Don't change the loop. Keep what you had before.

woven hazel
#

Alrighty

#

thanks for the suggestions.....?

arctic crypt
#

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.

opal mica
#

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

woven hazel
#

!close

high talonBOT
#
Python help channel closed

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.