Quick lesson. Comments are helpful for communicating ideas in our code. Sometimes we make a decision or write some code that may be unclear to others, or even to ourselves in the future. Comments are helpful reminders of what we need to know. We use the # symbol for single line comments.
3: Comments and Readable Layout
Readable code is easier to debug and maintain. Comments explain why code exists, not obvious steps.
Contributed by Bijou Raj
We can also block out whole lines of text with three ". This is used for other purposes as well, but for now, it is okay to use these to comment out massive chunks of text.
In addition to comments being helpful to understanding our written code, they can help us in the writing process as well. Commenting things out when we don't want them to run can be very helpful for debugging. Take this, for example.
There's a lot going on here, but what if something was broken? It could be difficult to find out where it was if we executed the entire block in each iteration, so let's get rid of some of the noise.
This can help us isolate smaller sections of our code. Try it out on the next exercises.
We only want to print out Good.
Print out only the value of hm.
Uncomment the lines that will get us to print: John is five years old.