til

Comments

Comments should not explain what the code does, but why it does it. The code should be self-explanatory, and comments should be used to explain the reasoning behind the code.

# Bad
# This function adds two numbers
def add(a, b):
    return a + b

# Good
def add(a, b):
    # We need to add the two numbers because we need the sum for the next step
    return a + b