[{"data":1,"prerenderedAt":1345},["ShallowReactive",2],{"doc-\u002Flearn\u002Fpython-pass-statement-explained":3},{"id":4,"title":5,"body":6,"description":1338,"extension":1339,"meta":1340,"navigation":179,"path":1341,"seo":1342,"stem":1343,"__hash__":1344},"content\u002Flearn\u002Fpython-pass-statement-explained.md","Python pass Statement Explained",{"type":7,"value":8,"toc":1289},"minimark",[9,19,26,32,37,69,75,82,87,90,103,106,109,145,148,204,209,219,228,234,237,248,251,264,269,275,291,294,308,315,322,325,389,392,401,408,412,417,466,469,478,490,494,497,537,540,549,556,560,565,619,622,646,653,657,663,727,730,739,742,748,751,755,758,761,780,783,787,792,813,819,827,830,850,859,865,870,873,893,903,920,923,976,979,1009,1019,1029,1035,1038,1068,1071,1097,1100,1119,1122,1143,1146,1173,1180,1184,1191,1194,1204,1213,1219,1222,1229,1232,1239,1242,1246,1282,1285],[10,11,13,14,18],"h1",{"id":12},"python-pass-statement-explained","Python ",[15,16,17],"code",{},"pass"," Statement Explained",[20,21,22,23,25],"p",{},"The Python ",[15,24,17],{}," statement is used when Python expects a block of code, but you do not want to add any real code yet.",[20,27,28,29,31],{},"Beginners often see ",[15,30,17],{}," in early practice programs, unfinished functions, or simple examples. It helps you write the structure of your program first without causing a syntax error.",[33,34,36],"h2",{"id":35},"quick-example","Quick example",[38,39,44],"pre",{"className":40,"code":41,"language":42,"meta":43,"style":43},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","if True:\n    pass\n","python","",[15,45,46,63],{"__ignoreMap":43},[47,48,51,55,59],"span",{"class":49,"line":50},"line",1,[47,52,54],{"class":53},"sVHd0","if",[47,56,58],{"class":57},"s39Yj"," True",[47,60,62],{"class":61},"sP7_E",":\n",[47,64,66],{"class":49,"line":65},2,[47,67,68],{"class":53},"    pass\n",[20,70,71,72,74],{},"Use ",[15,73,17],{}," when Python requires an indented block but you do not want to run any code yet.",[33,76,78,79,81],{"id":77},"what-the-pass-statement-does","What the ",[15,80,17],{}," statement does",[20,83,84,86],{},[15,85,17],{}," is a placeholder statement.",[20,88,89],{},"When Python runs it:",[91,92,93,97,100],"ul",{},[94,95,96],"li",{},"It does nothing",[94,98,99],{},"It produces no output",[94,101,102],{},"It does not change the program state",[20,104,105],{},"Its main purpose is to keep a block of code valid.",[20,107,108],{},"Python requires an indented block after lines that end with a colon, such as:",[91,110,111,115,120,125,130,135,140],{},[94,112,113],{},[15,114,54],{},[94,116,117],{},[15,118,119],{},"for",[94,121,122],{},[15,123,124],{},"while",[94,126,127],{},[15,128,129],{},"def",[94,131,132],{},[15,133,134],{},"class",[94,136,137],{},[15,138,139],{},"try",[94,141,142],{},[15,143,144],{},"except",[20,146,147],{},"For example:",[38,149,151],{"className":40,"code":150,"language":42,"meta":43,"style":43},"if 5 > 3:\n    pass\n\nprint(\"Done\")\n",[15,152,153,170,174,181],{"__ignoreMap":43},[47,154,155,157,161,165,168],{"class":49,"line":50},[47,156,54],{"class":53},[47,158,160],{"class":159},"srdBf"," 5",[47,162,164],{"class":163},"smGrS"," >",[47,166,167],{"class":159}," 3",[47,169,62],{"class":61},[47,171,172],{"class":49,"line":65},[47,173,68],{"class":53},[47,175,177],{"class":49,"line":176},3,[47,178,180],{"emptyLinePlaceholder":179},true,"\n",[47,182,184,188,191,195,199,201],{"class":49,"line":183},4,[47,185,187],{"class":186},"sptTA","print",[47,189,190],{"class":61},"(",[47,192,194],{"class":193},"sjJ54","\"",[47,196,198],{"class":197},"s_sjI","Done",[47,200,194],{"class":193},[47,202,203],{"class":61},")\n",[205,206,208],"h3",{"id":207},"output","Output",[38,210,212],{"className":40,"code":211,"language":42,"meta":43,"style":43},"Done\n",[15,213,214],{"__ignoreMap":43},[47,215,216],{"class":49,"line":50},[47,217,211],{"class":218},"su5hD",[20,220,221,222,224,225,227],{},"The ",[15,223,54],{}," block is valid because it contains ",[15,226,17],{},", even though nothing happens inside it.",[33,229,231,232],{"id":230},"why-beginners-need-pass","Why beginners need ",[15,233,17],{},[20,235,236],{},"Python does not allow empty code blocks.",[20,238,239,240,247],{},"If you write the start of a block and leave it empty, Python raises an error. This is one reason beginners often run into ",[241,242,244],"a",{"href":243},"\u002Ferrors\u002Findentationerror-expected-an-indented-block-fix",[15,245,246],{},"IndentationError: expected an indented block",".",[20,249,250],{},"For example, this is invalid:",[38,252,254],{"className":40,"code":253,"language":42,"meta":43,"style":43},"if True:\n",[15,255,256],{"__ignoreMap":43},[47,257,258,260,262],{"class":49,"line":50},[47,259,54],{"class":53},[47,261,58],{"class":57},[47,263,62],{"class":61},[20,265,266,267,247],{},"Python expects something indented under that ",[15,268,54],{},[20,270,271,272,274],{},"Using ",[15,273,17],{}," solves that problem:",[38,276,277],{"className":40,"code":41,"language":42,"meta":43,"style":43},[15,278,279,287],{"__ignoreMap":43},[47,280,281,283,285],{"class":49,"line":50},[47,282,54],{"class":53},[47,284,58],{"class":57},[47,286,62],{"class":61},[47,288,289],{"class":49,"line":65},[47,290,68],{"class":53},[20,292,293],{},"This is useful when:",[91,295,296,299,302,305],{},[94,297,298],{},"You want to sketch your program first",[94,300,301],{},"You are building a function step by step",[94,303,304],{},"You know a block will be filled in later",[94,306,307],{},"You want your code to run without finishing every part yet",[33,309,311,312,314],{"id":310},"where-pass-is-commonly-used","Where ",[15,313,17],{}," is commonly used",[205,316,318,319,321],{"id":317},"inside-an-if-statement","Inside an ",[15,320,54],{}," statement",[20,323,324],{},"When planning logic, you may want to create the condition first.",[38,326,328],{"className":40,"code":327,"language":42,"meta":43,"style":43},"age = 15\n\nif age >= 18:\n    pass\nelse:\n    print(\"Too young\")\n",[15,329,330,341,345,360,364,372],{"__ignoreMap":43},[47,331,332,335,338],{"class":49,"line":50},[47,333,334],{"class":218},"age ",[47,336,337],{"class":163},"=",[47,339,340],{"class":159}," 15\n",[47,342,343],{"class":49,"line":65},[47,344,180],{"emptyLinePlaceholder":179},[47,346,347,349,352,355,358],{"class":49,"line":176},[47,348,54],{"class":53},[47,350,351],{"class":218}," age ",[47,353,354],{"class":163},">=",[47,356,357],{"class":159}," 18",[47,359,62],{"class":61},[47,361,362],{"class":49,"line":183},[47,363,68],{"class":53},[47,365,367,370],{"class":49,"line":366},5,[47,368,369],{"class":53},"else",[47,371,62],{"class":61},[47,373,375,378,380,382,385,387],{"class":49,"line":374},6,[47,376,377],{"class":186},"    print",[47,379,190],{"class":61},[47,381,194],{"class":193},[47,383,384],{"class":197},"Too young",[47,386,194],{"class":193},[47,388,203],{"class":61},[205,390,208],{"id":391},"output-1",[38,393,395],{"className":40,"code":394,"language":42,"meta":43,"style":43},"Too young\n",[15,396,397],{"__ignoreMap":43},[47,398,399],{"class":49,"line":50},[47,400,394],{"class":218},[20,402,403,404,247],{},"If you are still learning conditionals, see ",[241,405,407],{"href":406},"\u002Flearn\u002Fpython-if-statements-explained","Python if statements explained",[205,409,411],{"id":410},"inside-a-loop","Inside a loop",[20,413,414,416],{},[15,415,17],{}," can be used while testing loop structure.",[38,418,420],{"className":40,"code":419,"language":42,"meta":43,"style":43},"for number in range(3):\n    pass\n\nprint(\"Loop finished\")\n",[15,421,422,443,447,451],{"__ignoreMap":43},[47,423,424,426,429,432,435,437,440],{"class":49,"line":50},[47,425,119],{"class":53},[47,427,428],{"class":218}," number ",[47,430,431],{"class":53},"in",[47,433,434],{"class":186}," range",[47,436,190],{"class":61},[47,438,439],{"class":159},"3",[47,441,442],{"class":61},"):\n",[47,444,445],{"class":49,"line":65},[47,446,68],{"class":53},[47,448,449],{"class":49,"line":176},[47,450,180],{"emptyLinePlaceholder":179},[47,452,453,455,457,459,462,464],{"class":49,"line":183},[47,454,187],{"class":186},[47,456,190],{"class":61},[47,458,194],{"class":193},[47,460,461],{"class":197},"Loop finished",[47,463,194],{"class":193},[47,465,203],{"class":61},[205,467,208],{"id":468},"output-2",[38,470,472],{"className":40,"code":471,"language":42,"meta":43,"style":43},"Loop finished\n",[15,473,474],{"__ignoreMap":43},[47,475,476],{"class":49,"line":50},[47,477,471],{"class":218},[20,479,480,481,485,486,247],{},"This can be useful while learning ",[241,482,484],{"href":483},"\u002Flearn\u002Fpython-for-loops-explained","Python for loops"," or ",[241,487,489],{"href":488},"\u002Flearn\u002Fpython-while-loops-explained","Python while loops",[205,491,493],{"id":492},"inside-a-function","Inside a function",[20,495,496],{},"You can create a function now and finish it later.",[38,498,500],{"className":40,"code":499,"language":42,"meta":43,"style":43},"def greet():\n    pass\n\nprint(\"Function created\")\n",[15,501,502,514,518,522],{"__ignoreMap":43},[47,503,504,507,511],{"class":49,"line":50},[47,505,129],{"class":506},"sbsja",[47,508,510],{"class":509},"sGLFI"," greet",[47,512,513],{"class":61},"():\n",[47,515,516],{"class":49,"line":65},[47,517,68],{"class":53},[47,519,520],{"class":49,"line":176},[47,521,180],{"emptyLinePlaceholder":179},[47,523,524,526,528,530,533,535],{"class":49,"line":183},[47,525,187],{"class":186},[47,527,190],{"class":61},[47,529,194],{"class":193},[47,531,532],{"class":197},"Function created",[47,534,194],{"class":193},[47,536,203],{"class":61},[205,538,208],{"id":539},"output-3",[38,541,543],{"className":40,"code":542,"language":42,"meta":43,"style":43},"Function created\n",[15,544,545],{"__ignoreMap":43},[47,546,547],{"class":49,"line":50},[47,548,542],{"class":218},[20,550,551,552,247],{},"This is common when learning ",[241,553,555],{"href":554},"\u002Flearn\u002Fpython-functions-explained","Python functions",[205,557,559],{"id":558},"inside-a-class","Inside a class",[20,561,562,564],{},[15,563,17],{}," is often used in empty class definitions.",[38,566,568],{"className":40,"code":567,"language":42,"meta":43,"style":43},"class Person:\n    pass\n\nuser = Person()\nprint(type(user))\n",[15,569,570,580,584,588,601],{"__ignoreMap":43},[47,571,572,574,578],{"class":49,"line":50},[47,573,134],{"class":506},[47,575,577],{"class":576},"sbgvK"," Person",[47,579,62],{"class":61},[47,581,582],{"class":49,"line":65},[47,583,68],{"class":53},[47,585,586],{"class":49,"line":176},[47,587,180],{"emptyLinePlaceholder":179},[47,589,590,593,595,598],{"class":49,"line":183},[47,591,592],{"class":218},"user ",[47,594,337],{"class":163},[47,596,577],{"class":597},"slqww",[47,599,600],{"class":61},"()\n",[47,602,603,605,607,611,613,616],{"class":49,"line":366},[47,604,187],{"class":186},[47,606,190],{"class":61},[47,608,610],{"class":609},"sZMiF","type",[47,612,190],{"class":61},[47,614,615],{"class":597},"user",[47,617,618],{"class":61},"))\n",[205,620,208],{"id":621},"output-4",[38,623,625],{"className":40,"code":624,"language":42,"meta":43,"style":43},"\u003Cclass '__main__.Person'>\n",[15,626,627],{"__ignoreMap":43},[47,628,629,632,634,637,640,643],{"class":49,"line":50},[47,630,631],{"class":163},"\u003C",[47,633,134],{"class":506},[47,635,636],{"class":193}," '",[47,638,639],{"class":197},"__main__.Person",[47,641,642],{"class":193},"'",[47,644,645],{"class":163},">\n",[20,647,648,649,247],{},"This is a common pattern when starting with ",[241,650,652],{"href":651},"\u002Flearn\u002Fpython-classes-and-objects-explained","Python classes and objects",[205,654,656],{"id":655},"inside-exception-handling","Inside exception handling",[20,658,659,660,662],{},"During early debugging, you may temporarily leave an ",[15,661,144],{}," block empty.",[38,664,666],{"className":40,"code":665,"language":42,"meta":43,"style":43},"try:\n    number = int(\"abc\")\nexcept ValueError:\n    pass\n\nprint(\"Program continues\")\n",[15,667,668,674,695,704,708,712],{"__ignoreMap":43},[47,669,670,672],{"class":49,"line":50},[47,671,139],{"class":53},[47,673,62],{"class":61},[47,675,676,679,681,684,686,688,691,693],{"class":49,"line":65},[47,677,678],{"class":218},"    number ",[47,680,337],{"class":163},[47,682,683],{"class":609}," int",[47,685,190],{"class":61},[47,687,194],{"class":193},[47,689,690],{"class":197},"abc",[47,692,194],{"class":193},[47,694,203],{"class":61},[47,696,697,699,702],{"class":49,"line":176},[47,698,144],{"class":53},[47,700,701],{"class":609}," ValueError",[47,703,62],{"class":61},[47,705,706],{"class":49,"line":183},[47,707,68],{"class":53},[47,709,710],{"class":49,"line":366},[47,711,180],{"emptyLinePlaceholder":179},[47,713,714,716,718,720,723,725],{"class":49,"line":374},[47,715,187],{"class":186},[47,717,190],{"class":61},[47,719,194],{"class":193},[47,721,722],{"class":197},"Program continues",[47,724,194],{"class":193},[47,726,203],{"class":61},[205,728,208],{"id":729},"output-5",[38,731,733],{"className":40,"code":732,"language":42,"meta":43,"style":43},"Program continues\n",[15,734,735],{"__ignoreMap":43},[47,736,737],{"class":49,"line":50},[47,738,732],{"class":218},[20,740,741],{},"Be careful with this pattern. Ignoring errors can make bugs harder to find.",[33,743,745,747],{"id":744},"pass-vs-comments-vs-ellipsis",[15,746,17],{}," vs comments vs ellipsis",[20,749,750],{},"These are not the same.",[205,752,754],{"id":753},"comment","Comment",[20,756,757],{},"A comment is ignored by Python, but it does not count as a real statement by itself.",[20,759,760],{},"This still causes an error:",[38,762,764],{"className":40,"code":763,"language":42,"meta":43,"style":43},"if True:\n    # do this later\n",[15,765,766,774],{"__ignoreMap":43},[47,767,768,770,772],{"class":49,"line":50},[47,769,54],{"class":53},[47,771,58],{"class":57},[47,773,62],{"class":61},[47,775,776],{"class":49,"line":65},[47,777,779],{"class":778},"sutJx","    # do this later\n",[20,781,782],{},"Python sees the block as empty.",[205,784,785],{"id":17},[15,786,17],{},[20,788,789,791],{},[15,790,17],{}," is a real Python statement, so it makes the block valid.",[38,793,795],{"className":40,"code":794,"language":42,"meta":43,"style":43},"if True:\n    # do this later\n    pass\n",[15,796,797,805,809],{"__ignoreMap":43},[47,798,799,801,803],{"class":49,"line":50},[47,800,54],{"class":53},[47,802,58],{"class":57},[47,804,62],{"class":61},[47,806,807],{"class":49,"line":65},[47,808,779],{"class":778},[47,810,811],{"class":49,"line":176},[47,812,68],{"class":53},[20,814,815,816,818],{},"This works because ",[15,817,17],{}," is an actual statement.",[205,820,822,823,826],{"id":821},"ellipsis","Ellipsis (",[15,824,825],{},"...",")",[20,828,829],{},"You may sometimes see this:",[38,831,833],{"className":40,"code":832,"language":42,"meta":43,"style":43},"def my_function():\n    ...\n",[15,834,835,844],{"__ignoreMap":43},[47,836,837,839,842],{"class":49,"line":50},[47,838,129],{"class":506},[47,840,841],{"class":509}," my_function",[47,843,513],{"class":61},[47,845,846],{"class":49,"line":65},[47,847,849],{"class":848},"s_hVV","    ...\n",[20,851,852,853,855,856,858],{},"This is valid Python, but ",[15,854,17],{}," is usually clearer for beginners. If your goal is an intentionally empty block, ",[15,857,17],{}," is the better choice.",[33,860,862,863],{"id":861},"when-not-to-use-pass","When not to use ",[15,864,17],{},[20,866,867,869],{},[15,868,17],{}," is helpful, but it should not be used carelessly.",[20,871,872],{},"Do not use it when:",[91,874,875,878,887,890],{},[94,876,877],{},"You are hiding unfinished important logic for a long time",[94,879,880,881,485,884],{},"You actually need loop control like ",[15,882,883],{},"break",[15,885,886],{},"continue",[94,888,889],{},"The block should contain real behavior",[94,891,892],{},"You only forgot to finish your code",[20,894,895,896,898,899,485,901,247],{},"A common mistake is confusing ",[15,897,17],{}," with ",[15,900,886],{},[15,902,883],{},[91,904,905,910,915],{},[94,906,907,909],{},[15,908,17],{}," does nothing",[94,911,912,914],{},[15,913,886],{}," skips to the next loop iteration",[94,916,917,919],{},[15,918,883],{}," stops the loop completely",[20,921,922],{},"Example:",[38,924,926],{"className":40,"code":925,"language":42,"meta":43,"style":43},"for number in range(5):\n    if number == 2:\n        pass\n    print(number)\n",[15,927,928,945,960,965],{"__ignoreMap":43},[47,929,930,932,934,936,938,940,943],{"class":49,"line":50},[47,931,119],{"class":53},[47,933,428],{"class":218},[47,935,431],{"class":53},[47,937,434],{"class":186},[47,939,190],{"class":61},[47,941,942],{"class":159},"5",[47,944,442],{"class":61},[47,946,947,950,952,955,958],{"class":49,"line":65},[47,948,949],{"class":53},"    if",[47,951,428],{"class":218},[47,953,954],{"class":163},"==",[47,956,957],{"class":159}," 2",[47,959,62],{"class":61},[47,961,962],{"class":49,"line":176},[47,963,964],{"class":53},"        pass\n",[47,966,967,969,971,974],{"class":49,"line":183},[47,968,377],{"class":186},[47,970,190],{"class":61},[47,972,973],{"class":597},"number",[47,975,203],{"class":61},[205,977,208],{"id":978},"output-6",[38,980,982],{"className":40,"code":981,"language":42,"meta":43,"style":43},"0\n1\n2\n3\n4\n",[15,983,984,989,994,999,1004],{"__ignoreMap":43},[47,985,986],{"class":49,"line":50},[47,987,988],{"class":159},"0\n",[47,990,991],{"class":49,"line":65},[47,992,993],{"class":159},"1\n",[47,995,996],{"class":49,"line":176},[47,997,998],{"class":159},"2\n",[47,1000,1001],{"class":49,"line":183},[47,1002,1003],{"class":159},"3\n",[47,1005,1006],{"class":49,"line":366},[47,1007,1008],{"class":159},"4\n",[20,1010,1011,1012,1015,1016,1018],{},"Even when ",[15,1013,1014],{},"number == 2",", the loop continues normally because ",[15,1017,17],{}," does not skip anything.",[20,1020,1021,1022,1024,1025,247],{},"If you want to skip one iteration, use ",[15,1023,886],{}," instead. See ",[241,1026,1028],{"href":1027},"\u002Flearn\u002Fpython-break-and-continue-statements","Python break and continue statements",[33,1030,1032,1033],{"id":1031},"errors-related-to-missing-pass","Errors related to missing ",[15,1034,17],{},[20,1036,1037],{},"A missing block after one of these statements can cause an error:",[91,1039,1040,1044,1048,1052,1056,1060,1064],{},[94,1041,1042],{},[15,1043,54],{},[94,1045,1046],{},[15,1047,119],{},[94,1049,1050],{},[15,1051,124],{},[94,1053,1054],{},[15,1055,129],{},[94,1057,1058],{},[15,1059,134],{},[94,1061,1062],{},[15,1063,139],{},[94,1065,1066],{},[15,1067,144],{},[20,1069,1070],{},"This is especially common when:",[91,1072,1073,1079,1082,1085,1094],{},[94,1074,1075,1076,1078],{},"Writing an ",[15,1077,54],{}," statement and leaving the body empty",[94,1080,1081],{},"Creating a function skeleton without adding code",[94,1083,1084],{},"Adding only comments inside a class or function",[94,1086,1087,1088,898,1090,485,1092],{},"Confusing ",[15,1089,17],{},[15,1091,886],{},[15,1093,883],{},[94,1095,1096],{},"Forgetting that Python requires an indented block after a colon",[20,1098,1099],{},"For example, this causes an error:",[38,1101,1103],{"className":40,"code":1102,"language":42,"meta":43,"style":43},"def hello():\n    # add greeting later\n",[15,1104,1105,1114],{"__ignoreMap":43},[47,1106,1107,1109,1112],{"class":49,"line":50},[47,1108,129],{"class":506},[47,1110,1111],{"class":509}," hello",[47,1113,513],{"class":61},[47,1115,1116],{"class":49,"line":65},[47,1117,1118],{"class":778},"    # add greeting later\n",[20,1120,1121],{},"But this works:",[38,1123,1125],{"className":40,"code":1124,"language":42,"meta":43,"style":43},"def hello():\n    # add greeting later\n    pass\n",[15,1126,1127,1135,1139],{"__ignoreMap":43},[47,1128,1129,1131,1133],{"class":49,"line":50},[47,1130,129],{"class":506},[47,1132,1111],{"class":509},[47,1134,513],{"class":61},[47,1136,1137],{"class":49,"line":65},[47,1138,1118],{"class":778},[47,1140,1141],{"class":49,"line":176},[47,1142,68],{"class":53},[20,1144,1145],{},"If you want to check your file for syntax and indentation problems, you can run:",[38,1147,1151],{"className":1148,"code":1149,"language":1150,"meta":43,"style":43},"language-bash shiki shiki-themes material-theme-lighter github-light github-dark","python script.py\npython -m py_compile script.py\n","bash",[15,1152,1153,1160],{"__ignoreMap":43},[47,1154,1155,1157],{"class":49,"line":50},[47,1156,42],{"class":576},[47,1158,1159],{"class":197}," script.py\n",[47,1161,1162,1164,1168,1171],{"class":49,"line":65},[47,1163,42],{"class":576},[47,1165,1167],{"class":1166},"stzsN"," -m",[47,1169,1170],{"class":197}," py_compile",[47,1172,1159],{"class":197},[20,1174,1175,1176,247],{},"If Python reports an indentation-related problem, read ",[241,1177,1178],{"href":243},[15,1179,246],{},[33,1181,1183],{"id":1182},"faq","FAQ",[205,1185,1187,1188,1190],{"id":1186},"does-pass-do-anything-in-python","Does ",[15,1189,17],{}," do anything in Python?",[20,1192,1193],{},"No. It is a statement that does nothing, but it keeps the block syntactically valid.",[205,1195,1197,1198,1200,1201,1203],{"id":1196},"is-pass-the-same-as-continue","Is ",[15,1199,17],{}," the same as ",[15,1202,886],{},"?",[20,1205,1206,1207,1209,1210,1212],{},"No. ",[15,1208,17],{}," does nothing. ",[15,1211,886],{}," skips to the next loop iteration.",[205,1214,1216,1217,1203],{"id":1215},"can-i-use-a-comment-instead-of-pass","Can I use a comment instead of ",[15,1218,17],{},[20,1220,1221],{},"No. A comment does not count as a statement, so the block is still considered empty.",[205,1223,1225,1226,1228],{"id":1224},"can-pass-be-used-in-functions-and-classes","Can ",[15,1227,17],{}," be used in functions and classes?",[20,1230,1231],{},"Yes. It is often used in empty functions, classes, conditionals, and loops.",[205,1233,1235,1236,1238],{"id":1234},"should-i-leave-pass-in-finished-code","Should I leave ",[15,1237,17],{}," in finished code?",[20,1240,1241],{},"Only if the empty block is intentional. Otherwise, replace it with real logic.",[33,1243,1245],{"id":1244},"see-also","See also",[91,1247,1248,1254,1258,1263,1268,1273,1278],{},[94,1249,1250],{},[241,1251,1252],{"href":243},[15,1253,246],{},[94,1255,1256],{},[241,1257,407],{"href":406},[94,1259,1260],{},[241,1261,1262],{"href":483},"Python for loops explained",[94,1264,1265],{},[241,1266,1267],{"href":488},"Python while loops explained",[94,1269,1270],{},[241,1271,1272],{"href":554},"Python functions explained",[94,1274,1275],{},[241,1276,1277],{"href":651},"Python classes and objects explained",[94,1279,1280],{},[241,1281,1028],{"href":1027},[20,1283,1284],{},"If you keep learning Python block syntax, you will write cleaner code and avoid many common indentation errors.",[1286,1287,1288],"style",{},"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 .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--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 .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 .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}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 .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}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 .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}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 .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .stzsN, html code.shiki .stzsN{--shiki-light:#91B859;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":43,"searchDepth":65,"depth":65,"links":1290},[1291,1292,1296,1298,1312,1319,1323,1325,1337],{"id":35,"depth":65,"text":36},{"id":77,"depth":65,"text":1293,"children":1294},"What the pass statement does",[1295],{"id":207,"depth":176,"text":208},{"id":230,"depth":65,"text":1297},"Why beginners need pass",{"id":310,"depth":65,"text":1299,"children":1300},"Where pass is commonly used",[1301,1303,1304,1305,1306,1307,1308,1309,1310,1311],{"id":317,"depth":176,"text":1302},"Inside an if statement",{"id":391,"depth":176,"text":208},{"id":410,"depth":176,"text":411},{"id":468,"depth":176,"text":208},{"id":492,"depth":176,"text":493},{"id":539,"depth":176,"text":208},{"id":558,"depth":176,"text":559},{"id":621,"depth":176,"text":208},{"id":655,"depth":176,"text":656},{"id":729,"depth":176,"text":208},{"id":744,"depth":65,"text":1313,"children":1314},"pass vs comments vs ellipsis",[1315,1316,1317],{"id":753,"depth":176,"text":754},{"id":17,"depth":176,"text":17},{"id":821,"depth":176,"text":1318},"Ellipsis (...)",{"id":861,"depth":65,"text":1320,"children":1321},"When not to use pass",[1322],{"id":978,"depth":176,"text":208},{"id":1031,"depth":65,"text":1324},"Errors related to missing pass",{"id":1182,"depth":65,"text":1183,"children":1326},[1327,1329,1331,1333,1335],{"id":1186,"depth":176,"text":1328},"Does pass do anything in Python?",{"id":1196,"depth":176,"text":1330},"Is pass the same as continue?",{"id":1215,"depth":176,"text":1332},"Can I use a comment instead of pass?",{"id":1224,"depth":176,"text":1334},"Can pass be used in functions and classes?",{"id":1234,"depth":176,"text":1336},"Should I leave pass in finished code?",{"id":1244,"depth":65,"text":1245},"Master python pass statement explained in our comprehensive Python beginner guide.","md",{},"\u002Flearn\u002Fpython-pass-statement-explained",{"title":5,"description":1338},"learn\u002Fpython-pass-statement-explained","-CC3wRS5WqH9DYWoLpSKZJ_tEks7eHsHKHmMKArNpU8",1777585504286]