#π I want to know if my code is efficient or needlessly complicated
36 messages Β· Page 1 of 1 (latest)
Please react with β
to upload your file(s) to our paste bin, which is more accessible for some users.
@eager ravine
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.
That's ok, but I'd be unlikely to write it that way just for readability
I'd likely use a loop
i see. well, i haven't learned about loops yet, but i will keep that in mind. thank you <3
it's good though that you already see that it's best not to repeat yourself in code
:D
if it's me I would keep message as is and do .upper() when printing
secondly to that I'd use uppermessage like your first one because it's clearer whats going on
for better readability
?
that makes sense
like you mean you would do this one?
you don't even really need a new variable
print(message.upper(), '!!!')
!e
message = 'Hello'
for i in range(3):
print(f'{message.upper()}!!!')
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | HELLO!!!
002 | HELLO!!!
003 | HELLO!!!
so that's how loops work?
it's one example, yes
that looks really cool, both readability and efficiency
so there are various ways to do loops?
python has for and while keywords for creating loops
hmmm
i see
i will learn more about loops in the future im using this one github tutorial but i havent gotten to that point yet
range makes it very easy to make something loop "a certain number of times"
but this is interesting and helpful
you can try changing the number inside range(3) to see the result
it will print it as many times as the number says, right?
exactly π
gotcha, thank you for all the insight 
np!
!close
This help channel has been closed. 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.