

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Comments in Python
A hash sign (#) that is not inside a string literal begins a comment. All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them.
Example
#!/usr/bin/python # First comment print "Hello, Python!" # second comment
Output
This produces the following result −
Hello, Python!
You can type a comment on the same line after a statement or expression −
name = "Madisetti" # This is again comment
You can comment multiple lines as follows −
# This is a comment. # This is a comment, too. # This is a comment, too. # I said that already.
Following triple-quoted string is also ignored by Python interpreter and can be used as a multiline comments −
''' This is a multiline comment. '''
- Related Questions & Answers
- How do we provide comments in Python?
- Comments in Java
- Comments in C#
- Comments in Perl
- Java comments.
- HTML Comments
- CSS Comments
- How do we create multiline comments in Python?
- /** and /* in Java comments
- Explain Comments in JavaScript
- Executable Comments in Java
- Comments in C/C++
- Comments in Dart Programming
- Comments in Rust Programming
- Comments in Lua Programming
Advertisements