- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to put multi-line comments inside a Python dict()?
You can put comments like you normally would anywhere in a python script. But note that you can only put single line comments using #. Multiline comments act like strings and you cannot put just a string in between definition of a dict. For example, the following declaration is perfectly valid −
Example
testItems = { 'TestOne': 'Hello', # 'TestTwo': None, }
But the following is not −
testItems = { 'TestOne': 'Hello', """ Some random multiline comment """ }
- Related Articles
- How to put comments inside a Python dictionary?
- Java multi-line comments
- How to write multi-line comments in C#?
- How do we use multi-line comments in JavaScript?
- What is the difference between single-line and multi-line comments in JavaScript?
- How to create a long multi-line string in Python?
- How to execute Python multi-line statements in the one-line at command-line?
- How to put a title for a curved line in Python Matplotlib?
- Multi-Line printing in Python
- Multi-Line Statements in Python
- How to write single-line comments in C#?
- How to comment each condition in a multi-line if statement in Python?
- How do we write Multi-Line Statements in Python?
- How can we put comments in a column of existing MySQL table?
- Java single line comments.

Advertisements