Recent Posts

how to use python comment





Hello this is Juny.

we can add some description using comments in our python code.

python interpreter ignore the comments.
if you have a habit to leave comments in code, your code will be very readable.


use comment



there are 2 ways to leave comment in code.

you can make one line comment by adding # at the beginning of the line.
you can make multiple line comments by adding """ or ''' at the beginning and end of lines


let's check it in code



print("hello1")

#print("hello2")

print("hello3")



in first line, printing out "hello1"
in second line, there is print function but that is commented.
last line, printing out "hello3"

let's check the result.



python oneline comment



the commented line is not printed.
interpreter ignored that line.


and then, let's check multi line comment in code.



print("hello1")

"""
I am checking multi-line comments.
these lines will be ignored by interpreter.
"""


'''
print("hello3")
print("hello4")
print("hello5")
'''

print("hello6")




there are 6 print function lines.
some of them are commented from "hello3" to "hello5"
and also, some description is added in code.
that's covered with """

let's check the output





python multiple line comments


"hello1" and "hello6" are printed out.
something commented are not printed.






how to use python comment how to use python comment Reviewed by Juny on 7월 04, 2019 Rating: 5

댓글 없음:

Powered by Blogger.