Tips for learning and finding mistakes in your code
When learning how to code, testers often find it challenging to follow along and practice their learnings.
Based on my experiences while learning how to do Python programming, here are some tips that helped me, which I believe could help others as well when learning to code.
When you copy code from one location (example code, friend’s code) review each line of code going backward. What do you mean by reading the code backward? Start at the last line. Compare that line in your file to the same line in the example code. Once it’s exactly the same, move up to the next line. Do this until you get to the first line in the file.
Read what you have typed out loud, including saying each character by name.
When you make a mistake write down what mistake you made.
When learning to code, before you go to the next practice exercise, look at the mistakes you have made previously and try not to make them this time.
Practice translating the code to English by writing a comment above each line explaining to yourself what it does.
Try to break your code and then fix it.
Find as many different ways to break your code until you get tired or exhaust all possibilities.
Get a friend to break your code and you try to fix it.
Add extra “debug” print statements that print out the value of variables, and that tell you when you are inside a function and when you exit it etc.
Type help() in the interactive python interpreter for interactive help, or type help(object) for help about an object, to find information about python keywords e.g. help(input) will show the help information for the ‘input’ function.