Commenting Code

We'll cover the following

Commenting code

One essential use of comments is to comment out code that is not to be executed in the current run. There are various reasons for this. For example, we may want to temporarily block out functionality or experiment with the code.

Let’s create a to-do list that stores various items and also allows us to add and remove items. Suppose we only want to see what adding a value to the list does. To do this, we’ll use a comment to comment out the remove functionality for now.

Press + to interact
myToDoList = ['Python Comments', 'Python If-Else Commands', 'Python Loops']
myToDoList.append('Python Functions')
print("Current To-Do List =", myToDoList)
# myToDoList.remove('Python Comments')
# print("Updated To-Do List:", myToDoList)

Note: You can uncomment the code anytime to see it in action.