Comments ¶
We use comments to annotate what code is doing or explaining why. This helps other people to understand your code, and they can also be helpful if you haven't looked at your own code in a while. So far, we have written short code, but annotations become more important when you have written a lot of code.
Once Python sees the pound sign and recognizes that the line is a comment, it is completely ignored by the computer.
In [19]:
Copied!
# print(2 * 2) This will not print!
print(3 * 3)
# print(2 * 2) This will not print!
print(3 * 3)
9
This is important, because just like English or Hindi (or any other language!), Python is a language with very strict rules that need to be followed. Python is stricter than a human listener, though, and will just error if it can't understand the code.