What are comments in Python?
23May, 2022
How Can We Help?
Created On
byMatt
Print
You are here:
< Back
Maker of websites,
Teacher,
Cat enthusiast
Teacher,
Cat enthusiast
Latest posts by Matt (see all)
- The 2022 End of Year Website Update - 01/01/2023
- Celebrating Ada Lovelace day - 10/10/2022
- Website update 5/9/22 - 05/09/2022
When programming, comments are usually written into code to make it easier for humans to read and easier for people to understand what the code is doing.
They are little notes that explain what pieces of code do so that anyone else that looks at it will understand.
In Python we use the hashtag # to denote comments.
For example:
name = input("Please enter your name") # Ask user for name and store as variable called name
print("Hello ", name) # Output Hello and their name
Anything after the hashtag is ignored by Python, it is only there for humans to read.
You should always comment your code, as what may seem simple to you while you are programming, may not seem as simple when you come back to it after a while!
Matt
administrator
Maker of websites,
Teacher,
Cat enthusiast