How to write comments in Python
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
In Python, comments are denoted by the pound sign (#). Anything following a pound sign on the same line is ignored by the interpreter.
For example, the following is a single-line comment:
# This is a single-line comment
Multi-line comments can be created by using triple quotes, either single or double.
""" This is a multi-line comment """
or
''' This is a multi-line comment '''
It is a good practice to include comments in your code to explain what the code does, how it works, and why it's necessary. This makes your code more readable and easier to understand for others (or yourself) who may need to modify or debug it in the future.
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
Related Articles
Continue your learning journey with these related topics
Master Data Science in Days, Not Months 🚀
Skip the theoretical rabbit holes. Get practical data science skills delivered in bite-sized lessons – Approach used by real data scientist. Not bookworms. 📚