What is Comments in Python | Why used Comments?

 What is comments in Python?

  • Comments in Python are notes in your code that are not executed.
  • They help explain what the code is doing or provide additional context.

Why use comments?

Clarify Code : They make it easier to understand what the code does.

Document Changes : They help keep track of changes and reasons for modifications.

Help Others : They make it easier for others to understand your code.


In Python, there are two types of comments:

Single-Line Comment: Starts with # and is used for short notes.

Example:


Multi-Line Comment:  Uses triple quotes (""" or ''') to cover multiple lines.

Example:



Post a Comment

0 Comments