Python's comments start with an octothorpe character.

Table of contents
Writing a comment in Python
We have a Python program that prints out Hello!, pauses for a second, and then prints Goodbye! on the same line:
fromtimeimportsleepprint("Hello!",end="",flush=True)sleep(1)# ANSI code to clear current lineprint("\r\033[K",end="")print("Goodbye!")It prints Hello!:
~ $ python3 hello.py
Hello!
And then one second later it overwrites Hello! with Goodbye!:
~ $ python3 hello.py
Goodbye!
It does this using an ANSI escape code (that \033[K string).
The line above the print call in our code is called a comment:
# ANSI code to clear current lineprint("\r\033[K",end="")Python's comments all start with the # character.
I call this character an octothorpe, though it goes by many names.
Some of the more common names for # are hashmark, number sign, and pound sign.
You can write a comment in Python by putting an octothorpe character (#) at the beginning of a line, and then writing your comment.
The comment stops at the end of the line, meaning the next line is code... unless you write another octothorpe character!
Here we've written more details and added an additional line to note that this code doesn't yet work on Windows:
# ANSI code to clear current line: \r moves to beginning, \033[K erases to end.# Note: This will not work on Windows without code to enable ANSI escape codes.print("\r\033[K",end="")This is sometimes called a block comment because it's a way to write a block of text that represents a comment.
Unlike some programming languages, Python has no multiline comment syntax. If you think you've seen a multiline comment, it may have been a docstring or a multiline string. More on that in multiline comments in Python.
Inline comments in Python
Comments don't need to be …