r/learnpython • • 2h 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!

10 Upvotes

20 comments sorted by

14

u/jbenze 2h 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.

4

u/Warm_Letterhead3691 1h 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 1h ago

Can you guys give/show an example?

2

u/SharkSymphony 1h ago

Give us an example of something you want to do!

3

u/jipperthewoodchipper 1h 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 1h ago

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

1

u/Mundane_Emu_3 1h ago

Thank you so much everyone !

3

u/Both_Bend_2481 1h ago edited 1h 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 1h ago

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

2

u/Financial_Farm4326 1h 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

1

u/Narrow_Ad_8997 1h ago

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

1

u/Slothemo 1h 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.

1

u/Lyaw_Lyawa 1h ago

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

1

u/real_deal_engineer 1h 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.

1

u/_b10ck_h3ad_ 1h 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/SharkSymphony 1h ago

What problem are you trying to solve?

1

u/net_ramblings 2h ago

Klondike bar.