Comment

noun

say it: “KOM-ent” /ˈkɑmɛnt/

A note for people reading the code, starting with #; Python ignores everything from the # to the end of the line.

What is a comment in Python?

A comment is a note for people reading the code. Python ignores it. A comment starts with # and runs to the end of the line.

# Work out the total for the order
price = 12.50
quantity = 3
total = price * quantity  # 37.5

In a sentence

  • “The comment # prices include tax explains the next line.”
  • “She added a comment above the tricky loop so her teammates would follow it.”

Level: Novice · More Python terms at this level

Updated

In other subjects