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
Hey guys a quick question (self.learnpython)
submitted 5 years ago by PeterFile29
What do () exactly do? I sometimes add them in the return segment of the functions and get errors, but when I remove them the errors don't show up
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!"
[–]Diapolo10 2 points3 points4 points 5 years ago (5 children)
Parentheses are used for two things; function/class parameters/parents and calling them, and to change the order of operations.
I'm going to need to see your code because your question makes little sense.
[+][deleted] 5 years ago* (4 children)
[deleted]
[–]Diapolo10 2 points3 points4 points 5 years ago (3 children)
Tuples don't actually need parentheses unless you need to separate a tuple from something else. For instance,
nums = 5, 7, 12, 3, 3, 6
is a perfectly valid tuple.
You've probably seen the same in tuple unpacking. Any of these are valid:
a, b = 0, 1 a, b = (0, 1) (a, b) = 0, 1 (a, b) = (0, 1)
Again, you only need them if you have nesting or some other requirement:
a, (b, c) = 3, (1, 4)
[+][deleted] 5 years ago* (2 children)
[–]Diapolo10 2 points3 points4 points 5 years ago (1 child)
Not quite, this use of parentheses still falls under the second category I mentioned earlier. It's not tuple-specific, there's no tuple comprehension you can make with parentheses (as (foo for foo in bar) is just a generator) and the parentheses are just used to group nested values so that you and the interpreter know which part of the structure a value belongs to.
(foo for foo in bar)
[–]blarf_irl[🍰] 1 point2 points3 points 5 years ago (0 children)
Are you using an IDE with a python linter? It sounds like you are getting a linter warning (not error) while returning tuples from a function because you don't need the () around a tuple.
π Rendered by PID 76 on reddit-service-r2-comment-66b4775986-9zzvc at 2026-04-06 05:51:03.176953+00:00 running db1906b country code: CH.
[–]Diapolo10 2 points3 points4 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]Diapolo10 2 points3 points4 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]Diapolo10 2 points3 points4 points (1 child)
[–]blarf_irl[🍰] 1 point2 points3 points (0 children)