To write software is to experience constant failure until you get a success. When you start learning to write code, very little works, especially on your first try. You make a lot of mistakes. Maybe you copied example code to get started, then modify it to try and do something new. Reading errors to help you understand your mistakes is the only way forward. You can read documentation, search the web or chat with a language model to try and work through the problem, but it is inevitable that you will make mistakes when writing software.
We’re fortunate that the feedback loop to writing, executing and viewing the result of running software has been reduced significantly since its origins. When software used to be written on punch cards, developers used to painstakingly encode their instructions onto cards that would be fed into the system and run, often overnight. The next day, they could come and inspect their results. There is no doubt that incorrect instructions were written, and entire days lost due to this long feedback loop. Today, the speed of iteration and, more importantly, the speed of learning is much faster.
If I could give any advice to someone learning to code today, it would be to treat every failure as a learning opportunity and write short notes to summarize what you learned when you get something working. This practice helps you remember how far you have come, especially on days where it feels like nothing is going right. If you are new, keep in mind that even experienced developers make mistakes all day long.