Author -  Sai gowtham

Python - How to comment a block of code

In this tutorial, we are going to learn about how to comment a block of code in Python with the help of examples.

In Python, we can add a single line comment by using a # character followed by the comment.

Here is an example:

# this is a single line comment

Commenting a block of code

Python does’t provide any built-in syntax to comment a multiple lines unlike other programming languages.

To comment a block of code in python, add the # character infront of each line.

Example:

# price = 20
# print(price)
# name = 'raj'

or We can use the triple quotes """ syntax in Python.

The triple quotes syntax is normally used to create a multiline strings, but the string literals are ignored that are not assigned to a variable, so we are using it to add a multiline comment.

Here is an example:

"""
price = 20
print(price)
name = 'raj'

"""

Note: The multiline comment starts after the """ and ends before the """.

Any code or text, we add between """ and """ is ignored by the python compiler

Conclusion

Python doesn’t have a built-in way to comment a block of code like other programming languages, to add a block comment use # character infront of every line.

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY