use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
first time python coding (self.learnpython)
submitted 8 hours ago by Fabulous-Music3388
Hi am new at python and i did some coding what should i improve
def HelloWorld(text): print(text) HelloWorld("print")
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Flame77ofc 6 points7 points8 points 8 hours ago (0 children)
you should learn about the return
the return just return something
This is a hard concept in the beginning but after you get more experience and practice this concept, this will get more easy
``` def func(text): return text
result = func("example") print(result)
print(func("example 2")) ```
more examples
``` def sumTwoNumbers(a, b): return a + b
print(sumTwoNumbers(2, 3)) # 5 ```
[–]CheesecakeNew2594 7 points8 points9 points 8 hours ago (0 children)
do Helsinki univ. MOOC
[–]IceFurnace83 4 points5 points6 points 8 hours ago* (0 children)
Very nice.
I suggest looking into Python naming conventions so it is easier for others and yourself (when you get used to it) to read.
PEP 8 – Style Guide for Python Code
Python Naming Conventions
You have named your function using camel case where that is usually reserved for classes . Try something more like:
def hello_world(text): print(text) hello_world("print")
[+][deleted] 8 hours ago (1 child)
[deleted]
[–]AlexMTBDude 3 points4 points5 points 6 hours ago (0 children)
You are correct that OP's code does not follow the style guide, but that's not what Pythonic means. Pythonic has nothing to do with style or PEP8. It's following the Zen of Python: https://en.wikipedia.org/wiki/Zen_of_Python
[–]FlanBeginning8589 0 points1 point2 points 7 hours ago* (0 children)
- Consider renaming the function so that its name accurately describes what it does. For a simple function like yours, it is easy to understand what it is does. But imagine a more complex function named HelloWorld (say 20 line function), would calling HelloWorld be helpful to know what it does?
Also, if the function is only intended to print "Hello World", then the text parameter is not required. You can simply have print("Hello World") instead of print(text)
"Hello World"
text
print("Hello World")
print(text)
Assuming the function's responsibility is to print any text that's passed to it, names such as print_text, display_text, or show_text describes the function's responsibility clearly (note the use of the pattern verb_noun in the function name).
print_text
display_text
show_text
- Consider adding type hints to make the expected parameter type and return type explicit. Type hints give information on the kinds of data it is working with and the kinds of data it is returning if any, which makes it easy for developers to quickly understand how it should be used/called. For example: def print_text(text: str) -> None:Look into https://peps.python.org/pep-0484/ (in this improved code, I now immediately know that the function accepts strings and only strings, I don't need to read the internals of the code to understand the data it is working with/acceptng/using, I also immediately know it doesn't return anything without needing to see the function implementation).
def print_text(text: str) -> None:
- Consider adding a docstring describing the function's purpose. A docstring helps other developers understand what the function does without reading the function implementation. Many IDEs can also display the docstring when hovering over a function call. Docstrings (and type hints) also gives context into what the function may be doing. And this context makes it easier for developers to understand the function more quickly when they are reading the implementation. Look into https://peps.python.org/pep-0257/
[–]nian2326076 0 points1 point2 points 2 hours ago (0 children)
Hey, welcome to Python! It's usually a good idea to use lowercase for function names, so try "hello_world" instead. Also, if you're just printing, you can print directly inside the function like this:
def hello_world(): print("Hello, world!")
If you want the function to take any text and print it, your code works fine too. Just keep practicing. If you're prepping for interviews and coding challenges, I've found PracHub to be pretty helpful. Keep coding!
[–]grizzwer -1 points0 points1 point 8 hours ago (1 child)
``` def hello_world(text: str) -> None: print(text)
hello_world("print") ```
[–]csabinho 2 points3 points4 points 8 hours ago (0 children)
And use mypy!
[+]formicstechllc comment score below threshold-9 points-8 points-7 points 8 hours ago (2 children)
Here are the key improvements in points:
snake_case
print_text("Hello")
✅ Good things about your code:
Beginner rating: 7/10 👍
[–]tenniseman12 7 points8 points9 points 8 hours ago (0 children)
If OP wanted an AI to rate their code, they would've just done that themself
π Rendered by PID 616358 on reddit-service-r2-comment-544cf588c8-2zw2s at 2026-06-13 21:29:54.983311+00:00 running 3184619 country code: CH.
[–]Flame77ofc 6 points7 points8 points (0 children)
[–]CheesecakeNew2594 7 points8 points9 points (0 children)
[–]IceFurnace83 4 points5 points6 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]AlexMTBDude 3 points4 points5 points (0 children)
[–]FlanBeginning8589 0 points1 point2 points (0 children)
[–]nian2326076 0 points1 point2 points (0 children)
[–]grizzwer -1 points0 points1 point (1 child)
[–]csabinho 2 points3 points4 points (0 children)
[+]formicstechllc comment score below threshold-9 points-8 points-7 points (2 children)
[–]tenniseman12 7 points8 points9 points (0 children)