[{"data":1,"prerenderedAt":1289},["ShallowReactive",2],{"doc-\u002Flearn\u002Fpython-comments-explained-single-line-and-multi-line":3},{"id":4,"title":5,"body":6,"description":1282,"extension":1283,"meta":1284,"navigation":77,"path":1285,"seo":1286,"stem":1287,"__hash__":1288},"content\u002Flearn\u002Fpython-comments-explained-single-line-and-multi-line.md","Python Comments Explained (Single-Line and Multi-Line)",{"type":7,"value":8,"toc":1255},"minimark",[9,13,17,20,23,28,128,139,143,164,168,171,174,188,195,198,235,238,242,248,254,279,282,313,316,319,330,334,337,357,360,363,374,379,404,408,428,431,444,448,451,457,517,520,523,560,563,567,570,611,614,646,649,653,677,681,710,717,719,774,777,789,793,796,799,817,819,845,848,851,888,892,895,898,912,915,939,942,945,948,952,955,972,975,983,986,1011,1014,1022,1026,1029,1046,1049,1083,1086,1089,1123,1126,1141,1144,1173,1176,1180,1184,1190,1194,1200,1204,1207,1211,1214,1218,1221,1225,1251],[10,11,5],"h1",{"id":12},"python-comments-explained-single-line-and-multi-line",[14,15,16],"p",{},"Comments help you write code that is easier to read and understand.",[14,18,19],{},"In Python, comments are notes for humans. Python ignores them when it runs your program. This makes comments useful for explaining what your code does, why it exists, or what to watch out for.",[14,21,22],{},"This page shows you how to write comments in Python, when to use them, and how to avoid confusing comments with triple-quoted strings.",[24,25,27],"h2",{"id":26},"quick-example","Quick example",[29,30,35],"pre",{"className":31,"code":32,"language":33,"meta":34,"style":34},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","# Single-line comment\nname = \"Maya\"  # Inline comment\n\n\"\"\"\nThis is a multi-line string.\nIt is often used like a comment,\nbut it is not a real comment.\n\"\"\"\nprint(name)\n","python","",[36,37,38,47,72,79,86,93,99,105,110],"code",{"__ignoreMap":34},[39,40,43],"span",{"class":41,"line":42},"line",1,[39,44,46],{"class":45},"sutJx","# Single-line comment\n",[39,48,50,54,58,62,66,69],{"class":41,"line":49},2,[39,51,53],{"class":52},"su5hD","name ",[39,55,57],{"class":56},"smGrS","=",[39,59,61],{"class":60},"sjJ54"," \"",[39,63,65],{"class":64},"s_sjI","Maya",[39,67,68],{"class":60},"\"",[39,70,71],{"class":45},"  # Inline comment\n",[39,73,75],{"class":41,"line":74},3,[39,76,78],{"emptyLinePlaceholder":77},true,"\n",[39,80,82],{"class":41,"line":81},4,[39,83,85],{"class":84},"s2W-s","\"\"\"\n",[39,87,89],{"class":41,"line":88},5,[39,90,92],{"class":91},"sithA","This is a multi-line string.\n",[39,94,96],{"class":41,"line":95},6,[39,97,98],{"class":91},"It is often used like a comment,\n",[39,100,102],{"class":41,"line":101},7,[39,103,104],{"class":91},"but it is not a real comment.\n",[39,106,108],{"class":41,"line":107},8,[39,109,85],{"class":84},[39,111,113,117,121,125],{"class":41,"line":112},9,[39,114,116],{"class":115},"sptTA","print",[39,118,120],{"class":119},"sP7_E","(",[39,122,124],{"class":123},"slqww","name",[39,126,127],{"class":119},")\n",[14,129,130,134,135,138],{},[131,132,133],"strong",{},"Important:"," Use ",[36,136,137],{},"#"," for real comments. Triple quotes create a string, not a true comment.",[24,140,142],{"id":141},"what-this-page-helps-with","What this page helps with",[144,145,146,150,155,158,161],"ul",{},[147,148,149],"li",{},"Understand what a comment is",[147,151,152,153],{},"Write single-line comments with ",[36,154,137],{},[147,156,157],{},"Understand inline comments",[147,159,160],{},"Learn the common \"multi-line comment\" style",[147,162,163],{},"Avoid confusing comments with strings",[24,165,167],{"id":166},"what-a-comment-is-in-python","What a comment is in Python",[14,169,170],{},"A comment is text that Python ignores when running code.",[14,172,173],{},"Comments are useful because they help people reading the code:",[144,175,176,179,182,185],{},[147,177,178],{},"Explain what a step does",[147,180,181],{},"Explain why code was written a certain way",[147,183,184],{},"Add a short note before something tricky",[147,186,187],{},"Make code easier to come back to later",[14,189,190,191,194],{},"Comments do ",[131,192,193],{},"not"," change the result of your program.",[14,196,197],{},"Example:",[29,199,201],{"className":31,"code":200,"language":33,"meta":34,"style":34},"# Store the user's name\nname = \"Maya\"\n\nprint(name)\n",[36,202,203,208,221,225],{"__ignoreMap":34},[39,204,205],{"class":41,"line":42},[39,206,207],{"class":45},"# Store the user's name\n",[39,209,210,212,214,216,218],{"class":41,"line":49},[39,211,53],{"class":52},[39,213,57],{"class":56},[39,215,61],{"class":60},[39,217,65],{"class":64},[39,219,220],{"class":60},"\"\n",[39,222,223],{"class":41,"line":74},[39,224,78],{"emptyLinePlaceholder":77},[39,226,227,229,231,233],{"class":41,"line":81},[39,228,116],{"class":115},[39,230,120],{"class":119},[39,232,124],{"class":123},[39,234,127],{"class":119},[14,236,237],{},"When Python runs this code, it ignores the comment and only runs the real code.",[24,239,241],{"id":240},"how-to-write-a-single-line-comment","How to write a single-line comment",[14,243,244,245,247],{},"To write a comment in Python, start the line with ",[36,246,137],{},".",[14,249,250,251,253],{},"Everything after ",[36,252,137],{}," on that line is ignored.",[29,255,257],{"className":31,"code":256,"language":33,"meta":34,"style":34},"# This is a comment\nprint(\"Hello\")\n",[36,258,259,264],{"__ignoreMap":34},[39,260,261],{"class":41,"line":42},[39,262,263],{"class":45},"# This is a comment\n",[39,265,266,268,270,272,275,277],{"class":41,"line":49},[39,267,116],{"class":115},[39,269,120],{"class":119},[39,271,68],{"class":60},[39,273,274],{"class":64},"Hello",[39,276,68],{"class":60},[39,278,127],{"class":119},[14,280,281],{},"You can also use comments to explain the next step:",[29,283,285],{"className":31,"code":284,"language":33,"meta":34,"style":34},"# Ask the user for their age\nage = input(\"Enter your age: \")\n",[36,286,287,292],{"__ignoreMap":34},[39,288,289],{"class":41,"line":42},[39,290,291],{"class":45},"# Ask the user for their age\n",[39,293,294,297,299,302,304,306,309,311],{"class":41,"line":49},[39,295,296],{"class":52},"age ",[39,298,57],{"class":56},[39,300,301],{"class":115}," input",[39,303,120],{"class":119},[39,305,68],{"class":60},[39,307,308],{"class":64},"Enter your age: ",[39,310,68],{"class":60},[39,312,127],{"class":119},[14,314,315],{},"Single-line comments are best for short, clear notes.",[14,317,318],{},"Good comments are:",[144,320,321,324,327],{},[147,322,323],{},"Short",[147,325,326],{},"Specific",[147,328,329],{},"Easy to understand",[24,331,333],{"id":332},"inline-comments","Inline comments",[14,335,336],{},"An inline comment is written after code on the same line.",[29,338,340],{"className":31,"code":339,"language":33,"meta":34,"style":34},"name = \"Maya\"  # Save the user's name\n",[36,341,342],{"__ignoreMap":34},[39,343,344,346,348,350,352,354],{"class":41,"line":42},[39,345,53],{"class":52},[39,347,57],{"class":56},[39,349,61],{"class":60},[39,351,65],{"class":64},[39,353,68],{"class":60},[39,355,356],{"class":45},"  # Save the user's name\n",[14,358,359],{},"This can be helpful, but only when the comment adds useful context.",[14,361,362],{},"Use inline comments carefully:",[144,364,365,368,371],{},[147,366,367],{},"Good when the reason is not obvious",[147,369,370],{},"Bad when they only repeat the code",[147,372,373],{},"Too many can make code harder to read",[375,376,378],"h3",{"id":377},"good-inline-comment","Good inline comment",[29,380,382],{"className":31,"code":381,"language":33,"meta":34,"style":34},"total = price * 1.2  # Add 20% tax\n",[36,383,384],{"__ignoreMap":34},[39,385,386,389,391,394,397,401],{"class":41,"line":42},[39,387,388],{"class":52},"total ",[39,390,57],{"class":56},[39,392,393],{"class":52}," price ",[39,395,396],{"class":56},"*",[39,398,400],{"class":399},"srdBf"," 1.2",[39,402,403],{"class":45},"  # Add 20% tax\n",[375,405,407],{"id":406},"not-very-helpful","Not very helpful",[29,409,411],{"className":31,"code":410,"language":33,"meta":34,"style":34},"name = \"Maya\"  # Set name to Maya\n",[36,412,413],{"__ignoreMap":34},[39,414,415,417,419,421,423,425],{"class":41,"line":42},[39,416,53],{"class":52},[39,418,57],{"class":56},[39,420,61],{"class":60},[39,422,65],{"class":64},[39,424,68],{"class":60},[39,426,427],{"class":45},"  # Set name to Maya\n",[14,429,430],{},"The second comment does not add much. The code already makes that clear.",[14,432,433,434,439,440,247],{},"If you are still learning basic code structure, this fits well with ",[435,436,438],"a",{"href":437},"\u002Flearn\u002Fpython-syntax-basics-explained\u002F","Python syntax basics"," and ",[435,441,443],{"href":442},"\u002Flearn\u002Fpython-indentation-rules-and-why-they-matter\u002F","Python indentation rules",[24,445,447],{"id":446},"multi-line-comments-in-python","Multi-line comments in Python",[14,449,450],{},"Python does not have a special multi-line comment syntax.",[14,452,453,454,456],{},"The normal way to write a comment across several lines is to put ",[36,455,137],{}," at the start of each line:",[29,458,460],{"className":31,"code":459,"language":33,"meta":34,"style":34},"# This program asks for a name,\n# stores it in a variable,\n# and then prints a greeting.\nname = input(\"Enter your name: \")\nprint(\"Hello,\", name)\n",[36,461,462,467,472,477,496],{"__ignoreMap":34},[39,463,464],{"class":41,"line":42},[39,465,466],{"class":45},"# This program asks for a name,\n",[39,468,469],{"class":41,"line":49},[39,470,471],{"class":45},"# stores it in a variable,\n",[39,473,474],{"class":41,"line":74},[39,475,476],{"class":45},"# and then prints a greeting.\n",[39,478,479,481,483,485,487,489,492,494],{"class":41,"line":81},[39,480,53],{"class":52},[39,482,57],{"class":56},[39,484,301],{"class":115},[39,486,120],{"class":119},[39,488,68],{"class":60},[39,490,491],{"class":64},"Enter your name: ",[39,493,68],{"class":60},[39,495,127],{"class":119},[39,497,498,500,502,504,507,509,512,515],{"class":41,"line":88},[39,499,116],{"class":115},[39,501,120],{"class":119},[39,503,68],{"class":60},[39,505,506],{"class":64},"Hello,",[39,508,68],{"class":60},[39,510,511],{"class":119},",",[39,513,514],{"class":123}," name",[39,516,127],{"class":119},[14,518,519],{},"This is the standard way to write multi-line comments in Python.",[14,521,522],{},"Beginners often see triple quotes used like this:",[29,524,526],{"className":31,"code":525,"language":33,"meta":34,"style":34},"\"\"\"\nThis looks like a multi-line comment,\nbut Python treats it as a string.\n\"\"\"\nprint(\"Hello\")\n",[36,527,528,532,537,542,546],{"__ignoreMap":34},[39,529,530],{"class":41,"line":42},[39,531,85],{"class":84},[39,533,534],{"class":41,"line":49},[39,535,536],{"class":91},"This looks like a multi-line comment,\n",[39,538,539],{"class":41,"line":74},[39,540,541],{"class":91},"but Python treats it as a string.\n",[39,543,544],{"class":41,"line":81},[39,545,85],{"class":84},[39,547,548,550,552,554,556,558],{"class":41,"line":88},[39,549,116],{"class":115},[39,551,120],{"class":119},[39,553,68],{"class":60},[39,555,274],{"class":64},[39,557,68],{"class":60},[39,559,127],{"class":119},[14,561,562],{},"That style is common, but it is not a real comment.",[24,564,566],{"id":565},"triple-quotes-vs-real-comments","Triple quotes vs real comments",[14,568,569],{},"Triple quotes create a multi-line string.",[29,571,573],{"className":31,"code":572,"language":33,"meta":34,"style":34},"text = \"\"\"This is\na multi-line\nstring.\"\"\"\nprint(text)\n",[36,574,575,588,593,600],{"__ignoreMap":34},[39,576,577,580,582,585],{"class":41,"line":42},[39,578,579],{"class":52},"text ",[39,581,57],{"class":56},[39,583,584],{"class":60}," \"\"\"",[39,586,587],{"class":64},"This is\n",[39,589,590],{"class":41,"line":49},[39,591,592],{"class":64},"a multi-line\n",[39,594,595,598],{"class":41,"line":74},[39,596,597],{"class":64},"string.",[39,599,85],{"class":60},[39,601,602,604,606,609],{"class":41,"line":81},[39,603,116],{"class":115},[39,605,120],{"class":119},[39,607,608],{"class":123},"text",[39,610,127],{"class":119},[14,612,613],{},"Output:",[29,615,617],{"className":31,"code":616,"language":33,"meta":34,"style":34},"This is\na multi-line\nstring.\n",[36,618,619,627,638],{"__ignoreMap":34},[39,620,621,624],{"class":41,"line":42},[39,622,623],{"class":52},"This ",[39,625,626],{"class":56},"is\n",[39,628,629,632,635],{"class":41,"line":49},[39,630,631],{"class":52},"a multi",[39,633,634],{"class":56},"-",[39,636,637],{"class":52},"line\n",[39,639,640,643],{"class":41,"line":74},[39,641,642],{"class":52},"string",[39,644,645],{"class":119},".\n",[14,647,648],{},"That means triple-quoted text is different from a real comment.",[375,650,652],{"id":651},"real-comment","Real comment",[29,654,656],{"className":31,"code":655,"language":33,"meta":34,"style":34},"# Python ignores this line\nprint(\"Hello\")\n",[36,657,658,663],{"__ignoreMap":34},[39,659,660],{"class":41,"line":42},[39,661,662],{"class":45},"# Python ignores this line\n",[39,664,665,667,669,671,673,675],{"class":41,"line":49},[39,666,116],{"class":115},[39,668,120],{"class":119},[39,670,68],{"class":60},[39,672,274],{"class":64},[39,674,68],{"class":60},[39,676,127],{"class":119},[375,678,680],{"id":679},"triple-quoted-string","Triple-quoted string",[29,682,684],{"className":31,"code":683,"language":33,"meta":34,"style":34},"\"\"\"Python reads this as a string.\"\"\"\nprint(\"Hello\")\n",[36,685,686,696],{"__ignoreMap":34},[39,687,688,691,694],{"class":41,"line":42},[39,689,690],{"class":84},"\"\"\"",[39,692,693],{"class":91},"Python reads this as a string.",[39,695,85],{"class":84},[39,697,698,700,702,704,706,708],{"class":41,"line":49},[39,699,116],{"class":115},[39,701,120],{"class":119},[39,703,68],{"class":60},[39,705,274],{"class":64},[39,707,68],{"class":60},[39,709,127],{"class":119},[14,711,712,713,716],{},"In some places, triple-quoted strings are used as ",[131,714,715],{},"docstrings",". A docstring is a special string used to describe a module, function, class, or method.",[14,718,197],{},[29,720,722],{"className":31,"code":721,"language":33,"meta":34,"style":34},"def greet(name):\n    \"\"\"Return a friendly greeting.\"\"\"\n    return f\"Hello, {name}\"\n",[36,723,724,742,752],{"__ignoreMap":34},[39,725,726,730,734,736,739],{"class":41,"line":42},[39,727,729],{"class":728},"sbsja","def",[39,731,733],{"class":732},"sGLFI"," greet",[39,735,120],{"class":119},[39,737,124],{"class":738},"sFwrP",[39,740,741],{"class":119},"):\n",[39,743,744,747,750],{"class":41,"line":49},[39,745,746],{"class":84},"    \"\"\"",[39,748,749],{"class":91},"Return a friendly greeting.",[39,751,85],{"class":84},[39,753,754,758,761,764,767,769,772],{"class":41,"line":74},[39,755,757],{"class":756},"sVHd0","    return",[39,759,760],{"class":728}," f",[39,762,763],{"class":64},"\"Hello, ",[39,765,766],{"class":399},"{",[39,768,124],{"class":52},[39,770,771],{"class":399},"}",[39,773,220],{"class":64},[14,775,776],{},"Here, the triple-quoted text is not just a note. It is documentation attached to the function.",[14,778,779,780,784,785,247],{},"If you want to learn more about functions, see ",[435,781,783],{"href":782},"\u002Flearn\u002Fpython-functions-explained\u002F","Python functions explained",". If you are not sure what a module is, see ",[435,786,788],{"href":787},"\u002Fglossary\u002Fwhat-is-a-module-in-python\u002F","what is a module in Python",[24,790,792],{"id":791},"when-comments-are-helpful","When comments are helpful",[14,794,795],{},"Comments are most useful when they explain something the code does not clearly say on its own.",[14,797,798],{},"Helpful comments can:",[144,800,801,808,811,814],{},[147,802,803,804,807],{},"Explain ",[131,805,806],{},"why"," something is done",[147,809,810],{},"Mark important steps for beginners",[147,812,813],{},"Add a short note before more complex logic",[147,815,816],{},"Clarify unusual behavior or edge cases",[14,818,197],{},[29,820,822],{"className":31,"code":821,"language":33,"meta":34,"style":34},"# Use 1-based numbering because the report format starts at 1\nreport_number = user_index + 1\n",[36,823,824,829],{"__ignoreMap":34},[39,825,826],{"class":41,"line":42},[39,827,828],{"class":45},"# Use 1-based numbering because the report format starts at 1\n",[39,830,831,834,836,839,842],{"class":41,"line":49},[39,832,833],{"class":52},"report_number ",[39,835,57],{"class":56},[39,837,838],{"class":52}," user_index ",[39,840,841],{"class":56},"+",[39,843,844],{"class":399}," 1\n",[14,846,847],{},"This is useful because the reason may not be obvious just from reading the code.",[14,849,850],{},"Another example:",[29,852,854],{"className":31,"code":853,"language":33,"meta":34,"style":34},"# Skip empty lines to avoid counting blank input\nif line != \"\":\n    count += 1\n",[36,855,856,861,878],{"__ignoreMap":34},[39,857,858],{"class":41,"line":42},[39,859,860],{"class":45},"# Skip empty lines to avoid counting blank input\n",[39,862,863,866,869,872,875],{"class":41,"line":49},[39,864,865],{"class":756},"if",[39,867,868],{"class":52}," line ",[39,870,871],{"class":56},"!=",[39,873,874],{"class":60}," \"\"",[39,876,877],{"class":119},":\n",[39,879,880,883,886],{"class":41,"line":74},[39,881,882],{"class":52},"    count ",[39,884,885],{"class":56},"+=",[39,887,844],{"class":399},[24,889,891],{"id":890},"when-comments-are-not-helpful","When comments are not helpful",[14,893,894],{},"Comments can also make code worse if they are unnecessary or outdated.",[14,896,897],{},"Avoid comments like these:",[144,899,900,903,906,909],{},[147,901,902],{},"Comments that repeat obvious code",[147,904,905],{},"Comments that are no longer true",[147,907,908],{},"Very long comments that interrupt reading",[147,910,911],{},"Comments used instead of clear variable names",[14,913,914],{},"Example of an unhelpful comment:",[29,916,918],{"className":31,"code":917,"language":33,"meta":34,"style":34},"# Add 1 to count\ncount = count + 1\n",[36,919,920,925],{"__ignoreMap":34},[39,921,922],{"class":41,"line":42},[39,923,924],{"class":45},"# Add 1 to count\n",[39,926,927,930,932,935,937],{"class":41,"line":49},[39,928,929],{"class":52},"count ",[39,931,57],{"class":56},[39,933,934],{"class":52}," count ",[39,936,841],{"class":56},[39,938,844],{"class":399},[14,940,941],{},"The code already says that.",[14,943,944],{},"A better improvement might be a clearer variable name or cleaner code.",[14,946,947],{},"You should also avoid using comments to explain confusing code when you could rewrite the code more clearly.",[24,949,951],{"id":950},"best-practices-for-beginners","Best practices for beginners",[14,953,954],{},"If you are new to Python, these habits will help:",[144,956,957,960,963,966,969],{},[147,958,959],{},"Write comments in plain language",[147,961,962],{},"Keep comments short",[147,964,965],{},"Put comments close to the code they describe",[147,967,968],{},"Update comments when the code changes",[147,970,971],{},"Use comments to support readable code, not replace it",[14,973,974],{},"A good goal is this:",[144,976,977,980],{},[147,978,979],{},"Write code that is clear on its own",[147,981,982],{},"Add comments only where they truly help",[14,984,985],{},"For example:",[29,987,989],{"className":31,"code":988,"language":33,"meta":34,"style":34},"# Convert minutes to seconds before saving\nseconds = minutes * 60\n",[36,990,991,996],{"__ignoreMap":34},[39,992,993],{"class":41,"line":42},[39,994,995],{"class":45},"# Convert minutes to seconds before saving\n",[39,997,998,1001,1003,1006,1008],{"class":41,"line":49},[39,999,1000],{"class":52},"seconds ",[39,1002,57],{"class":56},[39,1004,1005],{"class":52}," minutes ",[39,1007,396],{"class":56},[39,1009,1010],{"class":399}," 60\n",[14,1012,1013],{},"This comment gives useful context without being too long.",[14,1015,1016,1017,1021],{},"You may also notice that Python code depends on clean layout and structure. That is one reason ",[435,1018,1020],{"href":1019},"\u002Flearn\u002Fpython-keywords-explained-beginner-guide\u002F","Python keywords"," and indentation rules matter when writing readable code.",[24,1023,1025],{"id":1024},"common-mistakes","Common mistakes",[14,1027,1028],{},"These are common comment-related mistakes beginners make:",[144,1030,1031,1034,1037,1040,1043],{},[147,1032,1033],{},"Using triple quotes and thinking they are always comments",[147,1035,1036],{},"Writing comments that only repeat the code",[147,1038,1039],{},"Leaving old comments after changing the code",[147,1041,1042],{},"Putting too many inline comments on one line",[147,1044,1045],{},"Mixing comments with code in a way that hurts readability",[14,1047,1048],{},"Example of cluttered code:",[29,1050,1052],{"className":31,"code":1051,"language":33,"meta":34,"style":34},"name = \"Maya\"  # user's name  # stored as text  # printed below\nprint(name)  # show name\n",[36,1053,1054,1069],{"__ignoreMap":34},[39,1055,1056,1058,1060,1062,1064,1066],{"class":41,"line":42},[39,1057,53],{"class":52},[39,1059,57],{"class":56},[39,1061,61],{"class":60},[39,1063,65],{"class":64},[39,1065,68],{"class":60},[39,1067,1068],{"class":45},"  # user's name  # stored as text  # printed below\n",[39,1070,1071,1073,1075,1077,1080],{"class":41,"line":49},[39,1072,116],{"class":115},[39,1074,120],{"class":119},[39,1076,124],{"class":123},[39,1078,1079],{"class":119},")",[39,1081,1082],{"class":45},"  # show name\n",[14,1084,1085],{},"This works, but it is harder to read than necessary.",[14,1087,1088],{},"A cleaner version:",[29,1090,1091],{"className":31,"code":200,"language":33,"meta":34,"style":34},[36,1092,1093,1097,1109,1113],{"__ignoreMap":34},[39,1094,1095],{"class":41,"line":42},[39,1096,207],{"class":45},[39,1098,1099,1101,1103,1105,1107],{"class":41,"line":49},[39,1100,53],{"class":52},[39,1102,57],{"class":56},[39,1104,61],{"class":60},[39,1106,65],{"class":64},[39,1108,220],{"class":60},[39,1110,1111],{"class":41,"line":74},[39,1112,78],{"emptyLinePlaceholder":77},[39,1114,1115,1117,1119,1121],{"class":41,"line":81},[39,1116,116],{"class":115},[39,1118,120],{"class":119},[39,1120,124],{"class":123},[39,1122,127],{"class":119},[14,1124,1125],{},"If you want to test your script while learning, you can run it from the terminal:",[29,1127,1131],{"className":1128,"code":1129,"language":1130,"meta":34,"style":34},"language-bash shiki shiki-themes material-theme-lighter github-light github-dark","python your_script.py\n","bash",[36,1132,1133],{"__ignoreMap":34},[39,1134,1135,1138],{"class":41,"line":42},[39,1136,33],{"class":1137},"sbgvK",[39,1139,1140],{"class":64}," your_script.py\n",[14,1142,1143],{},"You may also see beginners explore Python with:",[29,1145,1147],{"className":31,"code":1146,"language":33,"meta":34,"style":34},"help(print)\ndir(__builtins__)\n",[36,1148,1149,1160],{"__ignoreMap":34},[39,1150,1151,1154,1156,1158],{"class":41,"line":42},[39,1152,1153],{"class":115},"help",[39,1155,120],{"class":119},[39,1157,116],{"class":115},[39,1159,127],{"class":119},[39,1161,1162,1165,1167,1171],{"class":41,"line":49},[39,1163,1164],{"class":115},"dir",[39,1166,120],{"class":119},[39,1168,1170],{"class":1169},"s_hVV","__builtins__",[39,1172,127],{"class":119},[14,1174,1175],{},"These are not comment tools, but they can help you learn how Python works.",[24,1177,1179],{"id":1178},"faq","FAQ",[375,1181,1183],{"id":1182},"how-do-you-write-a-comment-in-python","How do you write a comment in Python?",[14,1185,1186,1187,1189],{},"Use ",[36,1188,137],{}," followed by your note. Python ignores the rest of that line.",[375,1191,1193],{"id":1192},"does-python-have-multi-line-comments","Does Python have multi-line comments?",[14,1195,1196,1197,1199],{},"Not as a separate syntax. The usual approach is to write ",[36,1198,137],{}," on each line.",[375,1201,1203],{"id":1202},"are-triple-quotes-comments-in-python","Are triple quotes comments in Python?",[14,1205,1206],{},"No. Triple quotes create a string. They are often used for docstrings.",[375,1208,1210],{"id":1209},"what-is-an-inline-comment","What is an inline comment?",[14,1212,1213],{},"It is a comment written after code on the same line.",[375,1215,1217],{"id":1216},"should-beginners-use-many-comments","Should beginners use many comments?",[14,1219,1220],{},"Use comments when they make code clearer, but do not comment every obvious line.",[24,1222,1224],{"id":1223},"see-also","See also",[144,1226,1227,1232,1237,1242,1246],{},[147,1228,1229],{},[435,1230,1231],{"href":437},"Python syntax basics explained",[147,1233,1234],{},[435,1235,1236],{"href":442},"Python indentation rules and why they matter",[147,1238,1239],{},[435,1240,1241],{"href":1019},"Python keywords explained",[147,1243,1244],{},[435,1245,783],{"href":782},[147,1247,1248],{},[435,1249,1250],{"href":787},"What is a module in Python?",[1252,1253,1254],"style",{},"html pre.shiki code .sutJx, html code.shiki .sutJx{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s2W-s, html code.shiki .s2W-s{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#032F62;--shiki-default-font-style:inherit;--shiki-dark:#9ECBFF;--shiki-dark-font-style:inherit}html pre.shiki code .sithA, html code.shiki .sithA{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#032F62;--shiki-default-font-style:inherit;--shiki-dark:#9ECBFF;--shiki-dark-font-style:inherit}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sFwrP, html code.shiki .sFwrP{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#24292E;--shiki-default-font-style:inherit;--shiki-dark:#E1E4E8;--shiki-dark-font-style:inherit}html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":34,"searchDepth":49,"depth":49,"links":1256},[1257,1258,1259,1260,1261,1265,1266,1270,1271,1272,1273,1274,1281],{"id":26,"depth":49,"text":27},{"id":141,"depth":49,"text":142},{"id":166,"depth":49,"text":167},{"id":240,"depth":49,"text":241},{"id":332,"depth":49,"text":333,"children":1262},[1263,1264],{"id":377,"depth":74,"text":378},{"id":406,"depth":74,"text":407},{"id":446,"depth":49,"text":447},{"id":565,"depth":49,"text":566,"children":1267},[1268,1269],{"id":651,"depth":74,"text":652},{"id":679,"depth":74,"text":680},{"id":791,"depth":49,"text":792},{"id":890,"depth":49,"text":891},{"id":950,"depth":49,"text":951},{"id":1024,"depth":49,"text":1025},{"id":1178,"depth":49,"text":1179,"children":1275},[1276,1277,1278,1279,1280],{"id":1182,"depth":74,"text":1183},{"id":1192,"depth":74,"text":1193},{"id":1202,"depth":74,"text":1203},{"id":1209,"depth":74,"text":1210},{"id":1216,"depth":74,"text":1217},{"id":1223,"depth":49,"text":1224},"Master python comments explained single line and multi line in our comprehensive Python beginner guide.","md",{},"\u002Flearn\u002Fpython-comments-explained-single-line-and-multi-line",{"title":5,"description":1282},"learn\u002Fpython-comments-explained-single-line-and-multi-line","96wn4tVwkYR_m6owMglraghBVIuBWMplTZ7uRQsaANo",1777585471562]