Commenting Your Code in Python


Use comments to explain the “why” behind your code, not the “what”. Your code itself should be clear enough to explain what it does.

Source Code

# Correct way to use comments
# Check if user is eligible for rewards rather than just stating the obvious
if user.age > 18 and user.points > 100:
    # Eligible for rewards
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments