r/learnpython • • Mar 11 '25

My code works and idk why

So basically, I'm new to python and programming in general. Recently I made a file organizer project that organize files based on the file extension (following a tutorial ofc). It works, it's cool. So then I head over to chatgpt and asked it to make an image organizer using the existing code that I have. And it works! It's really cool that it works, the problem is idk why. Even after asking chatgpt to explain it to me line by line, and asking it to explain to me like I'm a toddler, I still don't quite understand why anything works. My question is, is this normal for programmers? Sending your code to chatgpt, ask it to fix/refine the code, don't understand a thing its saying, and just going along with it? And, is this a good or optimal way to learn coding? Or is there a better way?

13 Upvotes

63 comments sorted by

View all comments

2

u/torkelspy Mar 11 '25

This is not a good way to learn. It can sometimes be helpful to go step by step through code you only kind of understand, but you need to have a strong base first. There are lots of recommendations for how to learn here

The "best way" to learn varies by person, but you definitely want to start off writing code yourself. Looking at examples is fine, but you want to put the examples "in your own words" so to speak. Look at how to do a thing, then try to do that thing on your own.