Welcome back to Edlitera's Intro to Programming series. Before we start diving into the Python programming language, one important thing I want to cover is how to get help if you get stuck. Programming can be frustrating for a beginner, especially when stumbled by cryptic error messages and things that should work but somehow don't. The Internet, of course, pretty much has all the answers. It is increasingly unlikely that you are the first person in the world running into a specific issue when it comes to programming, and over the years entire communities were built around documenting issues and solutions. So, be patient and don't get discouraged!
Generally my approach is as follows: first, I google it (or, if you don't use Google, use your preferred search engine). There are a couple of tips here. First, make sure you include the language name in your query. For example, if you forgot how to read a file, a good thing to search for is "python how to read files". If you don't include in your query the name of the specific programming languge you're using, you won't get relevant links, of course.
Errors are something that you will inevitably run into :( If you are seeing some error, it will often be accompanied by some text explaining what's going on. When searching online for a solution, I recommend that you use both the error message text and the name of the programming language (in our case Python).
Below, you can see an example of a Python script error. If you're curious, in this case, the issue is that the single and double quote don't match (more on this later in the course!).
Note how the error message provides both the type of error that occurred (SyntaxError), as well as some additional details (EOL while scanning string literal). The error description probably doesn't make much sense to a beginner, and I agree that errors can be a bit cryptic. However, this is enough information to begin searching for an answer.
When searching for answers to a particular issue, it is important to be specific. The more time you spend trying to understand the error or the issue yourself, the better you will be at explaining it and, therefore, the better you will be at searching for a solution. Avoid searching for things that are too general because, again, you will not get many relevant results.
Finally, pay attention to language versions. The Python programming language has some differences between versions, particularly between Python 2 and Python 3. When going over a solution, make sure it is a solution for your specific version (in this article series, we will only cover Python 3+). In fact, I would recommend, at least in the beginning, to also include the language version in your search, to make sure that you get solutions that are more relevant for your specific programming language version.
Sometimes (though pretty rarely), searching on the web does not lead to a solution. In this case, I will read the documentation. The Python 3 documentation can be found at: https://docs.python.org/3. Python has very good documentation, though sometimes it does take some familiarity with programming in general to understand parts of it, so when you're just getting started, things can again be a bit cryptic.
As you get more advanced, however, navigating and parsing the documentation will become easier. When using the documentation, one very important thing to pay attention to is the language version. That URL above takes us to the Python 3 documentation, but you can also find documentation for older versions of Python. Just make sure - particularly if you follow a link from somewhere on the internet - that the documentation is relevant to your programming language version!
The documentation is often useful, but in the beginning it can be a bit harder to find the things that are relevant to you. When an internet search fails you and the documentation is also not helpful, you can actually crowdsource an answer. The best community for asking and answering programming-related questions is by far StackOverflow. You can access it at https://stackoverflow.com. In fact, you probably should create an account there as soon as possible because it's free and you will definitely use it. StackOverflow is so popular that even if you just use a web search to find a solution, the answer will often come from StackOverflow. The beauty of it though is that after you create an account, you can ask your own questions.
In all my years of programming, I've rarely had to go beyond these 3 steps to find answers to my technical questions. When that happens, however, the ultimate source of truth is the actual source code of the programming language itself. Python being open sourced, anyone can have access to its code. However, that is an advanced topic and we will not cover it here.
One other thing to keep in mind is that the internet offers solutions to specific questions, so sometimes if you are running into a more complex issue, you need to spend some time upfront to break it down into smaller parts or questions you can ask online. Also, even if you do find a solution online, don't just copy paste it into your code. You will get a lot out of trying to understand why things are a certain way and then writing the code on your own.
So, to summarize, if you get stuck:
But, most importantly, be patient! Programming is not easy, but it is not impossibly hard either. A key to success is constant practice and the occasional refresher on the theory. Sometimes the best way to solve a problem is to step away from it for a little while and do something completely different. I've solved many, many problems that way.
If you still can't find an answer to your specific question, my advice to you is to simply move on and code something else. It is much better than banging your head against the walls, getting frustrated and then thinking that programming is just not for you. If you don't get something, or are running into an issue that you simply cannot solve, it is best to keep programming, just program something else. If this is an exercise you are doing, just write it down somewhere and move on to another exercise and come back to it in a few days, or a week. Keep doing that until you solve it.
As Duke Economics professor Dan Ariely once famously said, big data is a lot like teenage sex - everyone talks about it, no one really knows how to do it, everyone thinks everyone else is doing it, so everyone claims they are doing it.
Here's why you're never too old to learn programming.
It is said that, in business, as in life, we do not get what we deserve. We get what we negotiate for.