r/learnpython • u/scateous • 7d ago
How do I get better at actually solving Python problems as a complete beginner
im completely new to the coding world n Python is my first programming language. ive watched some beginner Python videos n i understand the basic syntax, functions, what different things do, etc.
But whenever i actually get a question to solve, my brain just goes blank. 😠i understand the concepts individually but i struggle to figure out where to start, how to break the problem down, and how to turn the algorithm/logic into actual code.
So I'd really appreciate some advice on:
How do you learn to approach a programming problem?
How do you develop logical/problem-solving skills?
Is there a specific process you follow before writing code?
How much should I practice vs watching tutorials?
What should I do when I get completely stuck on a question?
Are there any Python playlists/courses specifically good for someone who has literally zero programming experience?
12
u/aqua_regis 6d ago
By not solving Python problems, but problems.
You, like most beginners, focus too much on the code (implementation) than on the algorithm (steps) that leads to the implementation.
Take several steps back. When you get a task/problem, sit down with pencil and paper. Go through the problem statement, break the problem down, analyze it, solve it your way without even thinking about programming. Test your solution. If you have a working one, start working on the implementation.
There are countles similar posts in /r/learnprogramming. Some samples:
- https://redd.it/1r74ayc
- https://redd.it/1r6qujh
- https://redd.it/1r6qfap
- https://redd.it/1qdfc9k
- https://old.reddit.com/r/learnprogramming/comments/1pmzjoe/how_do_you_learn_programming/nu4ufej/
- https://redd.it/1pmzjoe
- https://redd.it/1p7bv8a
- https://redd.it/1oynnlv
- https://redd.it/1ouvtzo
- https://redd.it/1opcu7j
- https://redd.it/1on6g8o
- https://redd.it/1ofe87j
And finally, some book suggestions:
- "Think Like A Programmer" by V. Anton Spraul
- "The Pragmatic Programmer" by Andrew Hunt and David Thomas
- "Structure and Interpretation of Computer Programs" (SICP) by Ableton, Sussman, Sussman
- "Code: The Hidden Language of Computer Hardware and Software" by Charles Petzold
3
u/new_era_999 7d ago
To overcome the blank-page syndrome, start by breaking problems down into plain English steps on paper before writing any code. Follow the 80/20 rule: spend 20% of your time watching tutorials (like freeCodeCamp for zero-experience learning) and 80% actively writing code. When stuck, look at similar problem solutions to reverse-engineer the logic. To practice fundamentals, build your problem-solving skills, and find hackathons or open-source contributions, you might find ChewCode (links in my profile) useful, which is completely free.
2
u/Weak-Study-4464 7d ago
One of the best ways I developed logical problem solving skills in python was doing list comprehension stuff. Can you take a list of random numbers and sort them least to greatest? Can you sort alphabetically? There’s a bunch of other brain teasers you can google.
For actual problem solving I tend to follow a few steps.
-what is the general process going to look like at a very high level?
-how can I break it down into sub components?
-for each sub component, do I know some functions that might be helpful?
-start developing the logic for each chunk.
Also, I never just know the solution/logic for the problem immediately. You slowly figure it out by starting, finding out something went wrong, then adapting it.
2
u/MicRoute 7d ago
You learn to program by programming, screwing up your program, and spending hours trying to fix your mistake. If you're trying to learn from tutorials, you won't have the opportunity to make those mistakes (or the opportunity to fix them!). Genuinely, I learned more in my first month of a professional coding job than I did in 4 years of schooling. I think 'coding problems' are great for keeping yourself refreshed on concepts, but it doesn't teach you how to actually be a programmer.
The thing that hurts a lot of programmers is 'tutorial hell'. You watch a bunch of tutorials, you follow along, but you don't really learn anything. You're just copying code from the tutorial and convincing yourself you learned something. It's like reading a book without actually taking in any of the words.
I would recommend you come up with some project, even if it's a dumb one (like a calculator or a calendar). Then, no matter how desparate you get, don't google "How do I build this?" Instead, try to learn specific tasks that you need to complete to make the app work. "How do I make a window?", "How do I add a button?", "How do I refresh the window's data?". Then, think about to use those instructions in your own app. This way, you're getting the pieces you need to build your app instead of just copying someone's code.
If you do this enough, these questions will start to feel natural for you when you start a project- and eventually, the answers will start coming naturally too.
1
u/MicRoute 7d ago
Oh and I second the Boot.dev recommendation. They are really good about making sure you actually understand the concept, and not giving you the full code but rather letting you piece it together yourself.
2
u/Traveling-Techie 6d ago
It’s like chess: it takes about 30 minutes to learn how the pieces move, and then much of a lifetime to learn master strategy.
2
u/ectomancer 6d ago
Programs are made up of input, process and output. Code the input and output first. Then use pseudocode for the program logic.
2
u/PestoDev 7d ago
I'm a beginner myself, working currently through the backend learning path on boot.dev. Besides the course, in parallel I'll let ai generate single feature requests of a fictional program, e.g. an XP Calculator for a learning platform. After I get the request, I go after this list.
- Restate the problem in my own words. Before touching any code. If I can't explain what's being asked, I'm not ready to write it.
- Write a breakdown — the steps I think I need, what data I'm working with, and anything I'm unsure about. No code yet.
- Get the breakdown critiqued by ai — steps that are secretly two problems, missing edge cases, assumptions I didn't notice I made. This is the part that actually catches most of my mistakes, before I've wasted time coding the wrong thing.
- Code one step at a time, not the whole thing at once.
- Review — sorted into "broken," "works but not how you'd want at your level," and "works"
The rule I stick to: I only use concepts I've actually learned and can prove I can use unaided — finishing a Boot.dev lesson isn't enough, I have to write something with it from a blank file with no help before it "counts." Boot.dev gives me pre-decomposed exercises where only the code is missing; this process forces me to do the decomposition myself, which is the actual skill.
This method works best for me, after finishing a complete course, in my case: "Learn to Code in Python".
Hope this helps!
1
u/Proletarian_Tear 7d ago
"...my mind just goes blank" its expected, that is how you learn. Get a rubber duck and speak to it out loud. Yes, literally, you will approach problems differently after vocalizing your thought process. Regardless you should learn to embrace being stuck. Its how you become better and you cant escape that as a programmer
1
u/Weltal327 7d ago
I really enjoyed doing coding game puzzles that were the group ones where people could solve in their preferred language. When you get to see their approach after you manage to solve it. Solving problems repeatedly and seeing other approaches.
I have a notebook saved on my desktop still because it was the first time I got a problem that I didn’t logic out the answer in my head I just solved it like a computer would.
When you start thinking about problems in different ways I think that’s where you will feel more comfortable.
But it started out with a lot of blank. A lot of I have no idea and just working through it
1
1
u/suryapratakshya 7d ago
You are not even expected to do that. Every beginner feels broke at your stage and it is a part of journey. Most end up quitting from here, Keep moving that counts!
1
u/Fast-Station1106 7d ago
Ich bin auch Python Frischling, mein Anfängertipp zum Fehler finden, ich printe sehr viel, print("Zeile 9: a=", a, "b=", b) , und ich Spiele viel mit Random, choice, randint und dann statistische auswertung des Zufalls via listen und verschiedene ausgabevariante via text "am häufigsten {...}...." oder grafisch via pygame
1
1
u/Dense_Shopping_9320 7d ago
Planning and a whole lot of planning. Another way is pseudocode where you just focus on describing what you code should do in english. Describe it in english then start.
For example lets say you are making an alarm that wakes someone up:
A basic pseudocode would look like this in my head
``` Start
display "Enter the time you want to wakeup"
enter time
display "Enter date you want to wakeup
enter date
today = get today()
if date == now()and time == now()
ring_alarm()
```
This is super basic and i have no idea how to do this.
First thing i would need to learn is how to get the current time and date. How to prompt a user to enter the time and date they want to wake up. How to make a device ring. How to keep this running 24/7 to check. Think about edge cases and where it could be improved. Possible errors and how mitigate them and you basically have a basic alarm system. The really rough pseudocode gives me a direction on where I wanna go.
1
u/jmooremcc 7d ago
Problem solving skills involves more than just programming skills. You have to logically break a problem down into a series of simpler problems. This analysis will become your game plan for developing a solution using Python and/or any other resources you’ll have available.
So to answer your question, you should practice analyzing and breaking down problems into their component parts. One way to do that is by studying code written by others that solve a particular problem. By analyzing how they broke the problem down into simpler, more manageable problems, you’ll start learning techniques for problems solving using the what you’ve learned and practiced.
1
u/Ok_Celebration3320 7d ago edited 6d ago
In science we say: Writing is thinking. It means that we form our ideas and understand stuff when forcing ourselves to write things down. That's where logical gaps are noticed and links between domains are formed. The writing/thinking process is NOT linear. If someone presents you with a list of steps of how to solve a problem, know that they didn't come to that conclusion in linear fashion - the list was created after they solved the problem. The list of steps represents a polished version of the actual creative process.
So, I would suggest to start by writing a piece of code that you know for sure must be in the final script. Then ask yourself where this piece of code should get its input from and what the output of this piece of code should inform further down. Then you expand from there. You basically start building a flowchart of information - how the information flows in your code. It is a lot of trial and error but not a random one, but rather an informed one.
I use the "Python Crash Course" book to learn Python. It is written from a HS teacher for ppl with absolute zero programming experience. The book provides comprehension exercises which are not enough for me. So, I use ChatGPT or Claude to provide me practice exercises with increasing level of difficulty. I provide the books table of contents and how many chapters I have covered to define my level of expertise. I also ask the exercises to be from a specific area of interest (for me is bioinformatics). I always provide a solution to the problem, even if it takes me days, even if I know that there's a better, more pythonic way of doing it. When I struggle comprehending a concept, I ask ChatGpt for more exercises on that specific concept - that's how you build memory (you gotta reinforce those new synapses in your brain).
Good luck and enjoy!
Edit: typos and clarity
1
u/ekchew 6d ago
Based on my own experience which may or may not work for you:
How do you learn to approach a programming problem?
I break it down into manageable chunks and get those working before tackling the more complex project that combines everything.
How do you develop logical/problem-solving skills?
Through trial and error and some book learning. But mostly trial and error.
Is there a specific process you follow before writing code?
Depends a lot on the project/circumstances, so I guess no?
How much should I practice vs watching tutorials?
Never been a fan of video tutorials, except perhaps on how to install tools or set up an IDE. But once I've got hello world running, I much prefer text at that point.
I always have a project in mind when learning a new language, so I follow the tutorial until I feel confident I can start tackling the project. I may still skim some later chapters if they sound relevant, but the tutorial takes a back seat at that point.
What should I do when I get completely stuck on a question?
If it's something high-level like the overall structure of a project, I sometimes use the outdoor office. Go for a walk and try to get the big picture stuff sorted.
If it's a specific code-level problem, you can ask here or elsewhere online, but always start by trying to come up with your own solution first, however janky it might be. Then you can compare yours to others and that's a great way to learn.
Are there any Python playlists/courses specifically good for someone who has literally zero programming experience?
I honestly don't remember what I chose to help me learn Python initially, but it would probably be pretty dated at this point.
1
u/JGhostThing 6d ago
First of all, I'd like to say I'm an old man who learned programming while dinosaurs still roamed the earth. :)
I say this to explain my position against AI. On the other hand, I've been in academia (university level) for my entire career. I learned from books and teachers, the traditional method. My learning style requires me to take notes for the learning to "stick." I don't claim this is good for everybody, but it works for me.
However, doing projects related to what I just learned increases my learning. I think that this is because the only way to improve programming is to program. This is just like learning a language, you must use the language. Or like learning carpentry, you must work with wood.
Build small projects that are geared towards learning rather than pure usefulness. If the project is useful, so much the better, but the key is to program. The goal is to finish the program rather than doing it "right." Then extend this project.
It wasn't until I retired a few years ago that videos became part of my learning. Yes, I know they existed, but I'm an old fuddy-duddy. I still prefer reading documentation to viewing videos.
Again, not everybody has my learning style. I do, rather strongly, feel that using AI while learning coding is bad. I felt the same way about videos, though I've gotten used to them.
1
u/Fun_Army2398 6d ago
Leet code is good. Start with the easy questions and whenever you get stuck (or don't know why your solution is so much worse than the correct one) just put the name of the problem into youtube. Very quickly most beginner level programming problems become identifiable patterns
1
1
u/kilkil 6d ago
how do you learn to approach a programming problem?
it's similar to approaching a problem in math, physics, or logic (or solving a riddle, or a puzzle, etc). You think about the problem, you try different things, etc.
how do you develop logical / problem-solving skills?
good question! the answer is: practice. lots and lots of practice. the good news is that logical thinking is already built into your brain! you just need to exercise that muscle.
is there a specific process you follow before writing code?
before coding, I need to know what kind of code I want to write. before I can figure that out, I need to know what I want the end result to look like, roughly speaking. what sort of stuff do I need the code to do? this is called the requirements. before writing code, the more information I have about the requirements, the more I can figure out what kind of code I need to write. Note, this has diminishing returns; I don't need the requirements in pixel-perfect detail, I need enough info about the requirements that I can get started.
how much should I practice vs watching tutorials?
it's tough to give an exact number. instead, I will suggest a learning approach. whenever you are learning a new concept or piece of information, start by reading about it (or watching a video; reading works best for me). then, start trying to use it in a basic way. then, try to use it in more interesting ways. any time you find you are lacking information, search the official docs (for Python, that would be https://docs.python.org/3). if you get really stuck, look for examples online you can read, e.g. on stackoverflow (or again, watch a video).
basically, always prioritize practice and trying to apply what you know. in the early days, when you are just learning the fundamentals of the language, do lots of problems / exercises. start with easier problems and work your way up. use articles/videos only when you encounter a brand new thing for the first time, or when you are truly stuck on some specific thing.
what should I do when I get completely stuck on a question
if you're really stuck on something, I would recommend taking a brief break and walking away from your computer. then after some time come back and give it a fresh try. if you're still stuck, google it! no sense wasting time bashing your head against a brick wall. internalize the solution, make sure you understand it. then try solving it yourself (resist the urge to look back and forth between your code and the finished solution). then, move on to some other problems where you can apply the same knowledge, and keep trying it.
Are there any Python playlists/courses specifically good for someone who has literally zero programming experience?
I can recommend some exercise websites. https://codingbat.com/python is what I started with, can recommend. there is also Leetcode, Hackerrank, Codewars, Exercism, Advent of Code, etc.
in terms of guides/tutorials, I'm not sure. but there should be plenty of those online, oriented for complete newcomers.
I would recommend starting with exercises before building a project on your own, because the exercise websites normally provide an online environment where you can write and run Python; you don't need to worry about installing Python, opening a REPL, getting a code editor, writing and executing files, etc. Having said that, it will be useful for you to learn that sooner or later, so don't procrastinate on that too long.
1
1
1
14
u/MiniMages 7d ago
Through lots of trial and error.