Topic 5: Comments

A comment is a text that the compiler ignores but that is useful for programmers. Comments are normally used to annotate code for future reference. The compiler treats them as white space. You can use comments in testing to make certain lines of code inactive.

A Python comment is written using #

Example 1
  • #This is a comment
    print("Hello, World!")
Example 2
  • print("Hello, World!") #This is a comment
Example 3
  • #This is a comment
    #written in
    #more than just one line
    print("Hello, World!")