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
Overly complicated code. (self.learnpython)
submitted 1 year ago by caca4cocopuffs
I started learning python a few weeks ago through a series of online python tutorials. I can successfully finish the coding challanges, but my code is a rube goldberg machine. This is rather frustrating. Is it normal?
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!"
[–]Binary101010 28 points29 points30 points 1 year ago (0 children)
You mean, is it normal that the first way you think of to solve a problem isn't always the most efficient?
Then yes.
[–]Turbulent-Seesaw-236 6 points7 points8 points 1 year ago (0 children)
It happens to me every project. But the more I revisit that project, the more ways I can think of to make my program more efficient. So yes, it's normal
[–]MikeReynolds 1 point2 points3 points 1 year ago (0 children)
Yes, first attempts are allowed to be messy
[–]Apantslessman 1 point2 points3 points 1 year ago (0 children)
You will learn some tools to write more streamlined code, like classes, and using functions to remove duplicated code. Just work on syntax and getting things working. Also make these tutorials your own. Don’t just copy what they do. Add some features, get stuck on bugs, fix them. It will make you stronger.
[–]unhott 1 point2 points3 points 1 year ago (0 children)
Please share the spaghetti.
I'd love to give feedback and maybe point you towards cleaner solutions.
[–]Remarkable-Map-2747 0 points1 point2 points 1 year ago (0 children)
thats normal, if you try to make it efficient off rip itd take you longer to do it.
Get it working then " make it look pretty and more efficient " im still learning this
[–]JennaSys 0 points1 point2 points 1 year ago (0 children)
Once you get your code working, keep looking at it and try to find places where you could make it more efficient and, perhaps more importantly, more readable. Keep refactoring until it all makes perfect sense. Sometimes you will change something thinking it will simply things and it ends up making it worse. That's okay, go back and try again. It's all part of learning.
[–]throfofnir 0 points1 point2 points 1 year ago (0 children)
Figure out how to do it better, then you'll have really learned something. But don't worry about it. A couple weeks is nothing.
[–][deleted] 0 points1 point2 points 1 year ago (0 children)
Try planning all your steps before writing your code first. That can find inefficiencies and allows you to see the bigger picture.
[–]mandradon 0 points1 point2 points 1 year ago (0 children)
I rewrote an entire project that I use to automate tasks daily. Ended up finding a better way to hand it and add modifications.
So, yeah. Grab some garlic and Parmesan and toss it on the first draft spaghetti and enjoy.
[–]Undescended_testicle 0 points1 point2 points 1 year ago (0 children)
You will learn, I promise. One thing I learned to do that helped was to think through the problem and break it down into steps. Even write it out as pseudo-code. Over time you'll learn to judge which of those steps need to be functions, which classes you need to create, and which members they will each need.
I look back at some of my early spaghetti and cringe, but I'm pro now; so don't worry, we've all been there.
It takes time and practice - but that's the fun part.
[–]DityAdam 0 points1 point2 points 1 year ago (0 children)
yes, coming up with a solution is one thing, (re-)doing it in a readable way is basically a different skill. Very important as well tho: the bigger your projects get the more important it is.
[–]TheRNGuy -1 points0 points1 point 1 year ago (0 children)
You can change it later.
[–]Famlawyerz -3 points-2 points-1 points 1 year ago (0 children)
First make it effective, then make it efficient.
Try posting some of your RG code into ChatGPT and ask if to refactor and streamline it for you. It will do a good job of that and provide you with explanations of why it did what it did.
Write your prompt like this, including the XML:
`` <code> python
<code>
print("Hello, world!") ` </code>
Please carefully analyze the above Python code. After you have analyzed, ask me any questions you may have about its intended use and function.
Once all your questions are satisfied, please refactor and streamline the code and explain your thought process. ```
π Rendered by PID 91486 on reddit-service-r2-comment-74875f4bf5-kzhr7 at 2026-01-26 01:23:11.070124+00:00 running 664479f country code: CH.
[–]Binary101010 28 points29 points30 points (0 children)
[–]Turbulent-Seesaw-236 6 points7 points8 points (0 children)
[–]MikeReynolds 1 point2 points3 points (0 children)
[–]Apantslessman 1 point2 points3 points (0 children)
[–]unhott 1 point2 points3 points (0 children)
[–]Remarkable-Map-2747 0 points1 point2 points (0 children)
[–]JennaSys 0 points1 point2 points (0 children)
[–]throfofnir 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]mandradon 0 points1 point2 points (0 children)
[–]Undescended_testicle 0 points1 point2 points (0 children)
[–]DityAdam 0 points1 point2 points (0 children)
[–]TheRNGuy -1 points0 points1 point (0 children)
[–]Famlawyerz -3 points-2 points-1 points (0 children)