Comments, unlike the code itself, don't tell Python what to do. They're more like notes to yourself, and to other programmers who may want to modify or edit your code l ater, that sey, "This is why I wrote it this way." In Python, a comment starts with the pound (# ) characte r, which telts the interpreter to ignore the text after it until the end of the line. Each line of a comment must start with thiis charade.
As the following example shows, you can put comments on their own line or you can add them after a statement.
#The following example demonstrates
#printing hello world to the console print ("hello world") #this prints hello world
Was this article helpful?