r/learnpython • • 10h ago

I understand Python concepts, but I just can’t seem to develop the logic to solve problems. How did you overcome this?

I've gone through multiple Python courses and understand the basic concepts like if-else, loops, lists, dictionaries, functions, etc.
However, when it comes to solving problems on my own, I struggle a lot. I can manage very basic questions like addition, subtraction, reversing a string, or checking for palindromes, but beyond that, I just can't seem to figure out the logic.
I understand the concepts and can follow someone else's solution, but when faced with a new problem, I have no idea where to start or how to break it down.
For those who have been through this, how did you develop your problem-solving skills? What kind of practice or approach helped you learn to think logically and solve problems independently?
I'd really appreciate any advice!

18 Upvotes

30 comments sorted by

3

u/Mundane_Emu_3 10h ago

Thank you so much everyone !

21

u/jbenze 10h ago

Start by writing the problem out on paper and walking through how you would solve it in pseudo code. Break it down into pieces, write it out and THEN translate it into code.

6

u/Warm_Letterhead3691 10h ago

100% this. Writing out the problem and your solution helps you find the ways your solution does and doesn't work. Plus it naturally gives your script structure when you go to build it. You'll end up breaking it up on paper into ways that work well when you translate them to functions and classes

2

u/Odd-Major-9038 10h ago

Can you guys give/show an example?

1

u/SharkSymphony 9h ago

Give us an example of something you want to do!

4

u/jipperthewoodchipper 10h ago

Somewhere in one of the many boxes of stuff I have hoarded in my basement is a notebook filled with nothing but leet code problems that I solved on paper before trying to touch with code.

Back in the days when knowing how to solve tower of Hanoi was advantageous for technical interviews

2

u/jbenze 9h ago

I have stacks of yellow pads somewhere from interviews when you used to have to write code on paper.

1

u/remic_0726 4h ago

Tu veux faire quelque chose, liste les mots du contexte, les noms,
les verbes, les propriétés, regroupe les en paquet cohérent, et tu vas obtenir des classes (noms), methodes (verbes), attributs (propriété). Et une classe est elle même découpée souvent en sous classe, donc réapplique la même méthode.

5

u/Both_Bend_2481 10h ago edited 10h ago

Every third beginner posts a similar question. You need to put in the work and practice. Code whatever programs you want.

edit: Just out of curiosity, what's something else you've done that you've become accomplished at, if anything? An art, or an instrument, or anything else that required practice and study? And how good have you become at it?

2

u/Pristine-Staff-5250 10h ago

Adding to this, code even the programs you don’t want

4

u/Financial_Farm4326 10h ago

pseudocode is huge for this tbh. write out every single step as a comment in your file first, then go back and fill in the actual python syntax underneath each comment so youre not fighting the logic and the language at the same time

3

u/ReddyKiloWit 6h ago

My first programming class - way too long ago - didn't have any code. We learned to break down problems and processes, write out the steps and draw diagrams of the logic needed. (I still have my logic symbol template.) It seems like a lot of people skip over that part and jump right to coding which is really secondary to developing a program. As others have suggested, pick a problem and then break it down into what steps are needed to get to a solution, and don't worry about syntax or even what language you'll use. Then practice that over and over.

•

u/thequestison 54m ago

Is it possible to get a copy of your logic symbol template?

2

u/Slothemo 10h ago

This is extremely common for beginners, and it mostly comes down to practice. The more problems you solve, the more patterns you will start to see emerge in how things are solved.

I really recommend a challenge site like Codewars and just work through as many problems as you can to build up the repetition. Once you feel a bit more confident, you can start working on your own mini-projects.

2

u/real_deal_engineer 10h ago

This isn’t a Python problem. Forget Python and solve the problems in natural language or on paper using regular symbols and math. Only then can you translate it to any language, not just Python.

2

u/_b10ck_h3ad_ 10h ago

You basically have to develop your "thinking of real world problem in code based solution" brain, which comes with time & practice. It's highly recommended whenever learning a new programming language, to try & code up a simple game (e.g. tic tac toe) that incorporates the concepts you've learned so far.

1

u/Narrow_Ad_8997 10h ago

Puzzles... Advent of code starts tonight at midnight EST

1

u/Lyaw_Lyawa 10h ago

Diagramas de flujo. Es más fácil hacer algo con un paso a paso.

1

u/SharkSymphony 9h ago

What problem are you trying to solve?

1

u/Prasannah_i 8h ago

I faced a similar challenge when learning Python. Understanding syntax and developing problem-solving logic are two different skills.

What helped me was focusing on breaking problems into smaller steps rather than immediately trying to write code.

My approach is:

  1. Understand the problem and identify the expected input and output.
  2. Write the solution in simple English or pseudocode.
  3. Break the problem into smaller tasks.
  4. Think about which concepts are needed, such as loops, conditions, lists, or dictionaries.
  5. Try solving it independently before looking at other solutions.
  6. After solving it, explore alternative approaches and understand why they work.

I also recommend practicing small real-world problems instead of only watching tutorials. For example, working with CSV files, finding duplicate records, handling missing values, and calculating totals can improve logical thinking.

Most importantly, don't worry about struggling initially. Problem-solving improves with consistent practice. Focus on understanding the approach rather than memorizing solutions.

1

u/SFJulie 4h ago

https://adventofcode.com/

With this yearly progessive challenge you can put in practice theoritical knowledge and hone your skills!

1

u/not_the_boulder 2h ago

My professor said that programming is like a sport, you have to practice.

Take some free online courses. Go through some books, and go through the exercises. Half of a university education is being exposed to a catalogue of problems.

1

u/BUYTBUYT BUYT-1 1h ago

Also a thing I've found that works: work through several examples yourself, manually, up to a point where you start to get a feel for it, then pay attention to what you're doing.

•

u/Fragrant-Cheek-4273 44m ago

I think you should stop relying on tutorials for now. Solve small problems on your own. My tip is to explain the logic in english before coding.

1

u/net_ramblings 10h ago

Klondike bar.

0

u/Serious_Hunt_763 7h ago

You do not understand Python concepts, you think you do, but you honestly do not. You need to use them in practice or teach them to understand them, until then you are about as dumb as is an apple red? yes? why? what about green apples? yellow apples? what actually is an apple?