Saturday, January 4, 2025
HomeTechHow to Create Multiline Comments in Python

How to Create Multiline Comments in Python

Python does not have a specific syntax for multiline comments, but you can achieve this using:

  1. Consecutive # Symbols:
    Use # at the beginning of each line.

    python
    # This is a multiline comment
    # explaining the code logic.
  2. Triple Quotes:
    Use triple single (''') or double (""") quotes for documentation or temporary comments.

    python
    """
    This is a multiline comment
    often used for explanations.
    """

Note: Triple quotes are not true comments; they create a string, which is ignored if not assigned or used. Use # for actual comments.

RELATED ARTICLES

Leave a Reply

- Advertisment -

Most Popular

Who is Kaylee Hottle? 

Who is Jackie Christie?

Who is Taylor Paul? 

Who are the AC/DC?

Recent Comments