Difference between # and """ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Difference between # and """

What is the difference between between # and """? Which situations would exist in which one is used over the other?

18th Aug 2016, 11:16 PM
Devon McCauley
Devon McCauley - avatar
3 Answers
+ 4
Use # when you make code out commenting .. That makes code unexecutabe .. As the program running it skips this code. But """ """ it's used when you right the discription of what that code gonna do that may help you or any one when he going to see the code.. And the programe read it while working but it doesn't give any output. And # use for one line only. But """ """ can use in multilines. Wish that's helpful!
18th Aug 2016, 11:51 PM
Mustafa Gamal
Mustafa Gamal - avatar
+ 1
# is just the single line comment. However triple quotes are far more complex than that Its first way of using is used as multiple line string. In this way you can type single and double quote without any trouble. The 2nd mean is used as multiple line comments. You can almostly put it anywhere you like. The last usage of it is python doc. Just put it right after def clause like this: Def myfunc(): ''' This a doc for this function ''' Then you can access it by using__doc__ property
19th Aug 2016, 1:40 AM
looyea
+ 1
# only works on a single line. ''' can be used on multiple lines but they are more complicated
19th Aug 2016, 8:52 AM
andyl9