Leaving Comments in Code

You may want to put in a few words addressed not to Python but to humans, usually to explain to other readers of the code how you went about the logic of your code.

In Python, a comment is a piece of text that begins with a # (hash) sign and extends to the end of the line.

If you'd like to quickly comment or uncomment multiple lines of code, select the line(s) you wish to modify and use the following keyboard shortcut: CTRL + / (Windows) or CMD + / (Mac OS).

Last updated

Was this helpful?