why should you learn to write programsagain in all three types of errorspython is merely trying its hardest to do exactly what you have asked debugging when python spits out an error or even when it gives you result that is different from what you had intendedthen begins the hunt for the cause of the error debugging is the process of finding the cause of the error in your code when you are debugging programand especially if you are working on hard bugthere are four things to tryreading examine your coderead it back to yourselfand check that it says what you meant to say running experiment by making changes and running different versions often if you display the right thing at the right place in the programthe problem becomes obviousbut sometimes you have to spend some time to build scaffolding ruminating take some time to thinkwhat kind of error is itsyntaxruntimesemanticwhat information can you get from the error messagesor from the output of the programwhat kind of error could cause the problem you're seeingwhat did you change lastbefore the problem appearedretreating at some pointthe best thing to do is back offundoing recent changesuntil you get back to program that works and that you understand then you can start rebuilding beginning programmers sometimes get stuck on one of these activities and forget the others finding hard bug requires readingrunningruminatingand sometimes retreating if you get stuck on one of these activitiestry the others each activity comes with its own failure mode for examplereading your code might help if the problem is typographical errorbut not if the problem is conceptual misunderstanding if you don' understand what your program doesyou can read it times and never see the errorbecause the error is in your head running experiments can helpespecially if you run smallsimple tests but if you run experiments without thinking or reading your codeyou might fall into pattern call "random walk programming"which is the process of making random changes until the program does the right thing needless to sayrandom walk programming can take long time you have to take time to think debugging is like an experimental science you should have at least one hypothesis about what the problem is if there are two or more possibilitiestry to think of test that would eliminate one of them taking break helps with the thinking so does talking if you explain the problem to someone else (or even to yourself)you will sometimes find the answer before you finish asking the question but even the best debugging techniques will fail if there are too many errorsor if the code you are trying to fix is too big and complicated sometimes the best