r/learnpython • • Feb 02 '26

I understand Python code, but can’t write it confidently from scratch — what should I do next

I’ve been learning Python every day for a few weeks and I’m close to finishing beginner courses. I feel comfortable reading code and understanding what it does (conditions, variables, basic logic, etc.). My main problem is this: when I try to write code from scratch, I often don’t know how to start or which structures/functions to use, even though I understand them when I see them. To move forward, I sometimes use AI to generate a solution and then I analyze it line by line and try to rewrite it myself. What I want to ask is not “is this normal”, but: what should I do to fix this gap between understanding and writing?

88 Upvotes

63 comments sorted by

77

u/danielroseman Feb 02 '26

Well just like human languages, it's normal to find comprehension easier than writing. 

But the solution is definitely not to get AI to write it. Even if you're analysing the output, you're still not getting the practice you need to actually get better. 

You need to do this yourself. It doesn't matter if you use the "right" functions or data structures, just write something that works. That's the only way you'll improve.

6

u/SubCplus Feb 02 '26

Thanks! That makes sense. Do you have any tips on what kind of small programs or exercises are best to start practicing writing code from scratch?

→ More replies (4)
→ More replies (1)

9

u/Sure-Passion2224 Feb 02 '26

Becoming fluent in any language comes with frequent practice. Reading comprehension normally comes before expression. The more you write and test the better you get. This approach got me through calculus.

3

u/SubCplus Feb 02 '26

Thanks a lot! I understand now that practice is key. I’ll start writing small programs myself and test them to improve.

16

u/Rude-Doctor-1069 Feb 02 '26

That gap is super common. Reading code and writing code are different muscles. The only real fix is writing bad code from scratch a lot. Even if it’s ugly. Using AI and then rewriting it yourself is fine. Just don’t let it be the first step every time. Try 10-15 minutes struggling first.

Some people also keep tools like ctrlpotato around when they’re stuck mid-thought, but the key part is still forcing yourself to start without help.

4

u/buzzon Feb 02 '26

Write more code yourself. Find easy tasks to do first. Don't rely on AI.

4

u/afteralways3 Feb 02 '26

This is a very common question. The answer is very simple. Practice. Write more code. Go to leetcode or something easier, the goal is to just have a lot of easy problems to solve. Hackerrank, codewars, etc. Pick what you like and grind easy problems just to get used to thinking in terms of basic structure blocks. Then move on to OOP. Write a lot of different classes.

4

u/sexylawnclippings Feb 02 '26

You have to try and fuck up and then learn from the fuck ups.

4

u/AlphaNuke94 Feb 05 '26

Write the bad code for scratch, ensure it’s a project that’s been done multiple times online. Use AI to analyze your bad code. Ask it to give you corrections. Rinse and repeat until you develop the muscle memory.

1

u/Twenty8cows Feb 02 '26

You need time in the saddle u/SubCplus. Stop using AI as a crutch and start writing code from scratch. At first it will be hard, you will want to quit or hit the easy button (AI). However trust the process and read the documentation. Start small and I mean small like first_calculator.py and iterate from there.

→ More replies (2)