Comments are statements in a program that the compiler or interpreter ignores. Comments are often used to help explain code.
You begin a comment in Python using #, and that comments out anything after, on that line of code.
Commenting out code
#addition 7 + 5
Output
12
In the above example, we commented out the first line of code saying addition, and so it was ignored by the
interpreter. Of course, you wouldn't really need to create a comment here since it's obvious what the code is doing.
Consent to process your data
Hey there! We use third-party cookies to improve your experience on our website. By clicking ‘Accept’, you're permitting us to use cookies for analytics and site improvement.
Don't worry; your privacy matters to us! If you're uncomfortable with cookies, you can always click ‘Decline’ and enjoy browsing our content. Alternatively, you can revoke any
previous cookie preference by clicking 'Revoke'.
For more information, check our cookie policy and our privacy policy.
Comments
Comments are statements in a program that the compiler or interpreter ignores. Comments are often used to help explain code. You begin a comment in Python using #, and that comments out anything after, on that line of code.
Commenting out code
#addition
7 + 5
Output
12
In the above example, we commented out the first line of code saying addition, and so it was ignored by the interpreter. Of course, you wouldn't really need to create a comment here since it's obvious what the code is doing.