Comments are notes in your code that Python ignores. They’re there to help you (or others) understand what your code does. In Python, comments start with a # symbol.
Example:
# This line calculates the total price
total = price * quantityYou can also write comments next to code:
total = price * quantity # multiply price by quantityGood comments make your code easier to read and maintain. When working on a team or revisiting your code later, comments help explain why something is being done, not just what is being done.
Besides using comments, writing readable code with meaningful variable names helps others (and future you) understand what’s going on.
Compare this:
x = 3.99
y = 4
z = x * yTo this:
price = 3.99
quantity = 4
total = price * quantityClear, right?