[{"data":1,"prerenderedAt":1537},["ShallowReactive",2],{"doc-\u002Flearn\u002Fpython-keywords-explained-beginner-guide":3},{"id":4,"title":5,"body":6,"description":1530,"extension":1531,"meta":1532,"navigation":68,"path":1533,"seo":1534,"stem":1535,"__hash__":1536},"content\u002Flearn\u002Fpython-keywords-explained-beginner-guide.md","Python Keywords Explained (Beginner Guide)",{"type":7,"value":8,"toc":1491},"minimark",[9,13,17,20,28,33,41,147,152,179,182,186,189,192,211,214,254,260,276,282,286,289,292,314,317,327,339,343,346,351,366,373,377,402,409,413,428,435,439,445,452,456,485,488,492,514,517,521,524,528,531,534,552,555,593,599,603,606,608,625,628,668,671,687,699,703,706,837,842,870,874,912,916,935,938,946,950,956,985,988,991,1051,1056,1072,1075,1078,1127,1131,1134,1138,1141,1160,1163,1182,1186,1194,1197,1200,1208,1220,1223,1225,1250,1253,1257,1260,1263,1308,1317,1320,1331,1335,1345,1348,1359,1363,1366,1369,1392,1395,1399,1403,1412,1416,1419,1423,1429,1433,1442,1446,1449,1453,1487],[10,11,5],"h1",{"id":12},"python-keywords-explained-beginner-guide",[14,15,16],"p",{},"Python keywords are reserved words that have a special meaning in the language.",[14,18,19],{},"They matter because Python uses them to understand the structure of your code. If you use a keyword in the wrong place, you will usually get a syntax error. As a beginner, learning to recognize keywords will make Python code much easier to read.",[14,21,22,23,27],{},"You do ",[24,25,26],"strong",{},"not"," need to memorize every keyword right away. Start by understanding what keywords are, what they do, and how to avoid using them as names.",[29,30,32],"h2",{"id":31},"quick-way-to-check-python-keywords","Quick way to check Python keywords",[14,34,35,36,40],{},"Python includes a built-in module named ",[37,38,39],"code",{},"keyword"," that can show you the current keyword list and check whether a word is reserved.",[42,43,48],"pre",{"className":44,"code":45,"language":46,"meta":47,"style":47},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","import keyword\n\nprint(keyword.kwlist)\nprint(keyword.iskeyword(\"if\"))\nprint(keyword.iskeyword(\"name\"))\n","python","",[37,49,50,63,70,94,123],{"__ignoreMap":47},[51,52,55,59],"span",{"class":53,"line":54},"line",1,[51,56,58],{"class":57},"sVHd0","import",[51,60,62],{"class":61},"su5hD"," keyword\n",[51,64,66],{"class":53,"line":65},2,[51,67,69],{"emptyLinePlaceholder":68},true,"\n",[51,71,73,77,81,84,87,91],{"class":53,"line":72},3,[51,74,76],{"class":75},"sptTA","print",[51,78,80],{"class":79},"sP7_E","(",[51,82,39],{"class":83},"slqww",[51,85,86],{"class":79},".",[51,88,90],{"class":89},"skxfh","kwlist",[51,92,93],{"class":79},")\n",[51,95,97,99,101,103,105,108,110,114,118,120],{"class":53,"line":96},4,[51,98,76],{"class":75},[51,100,80],{"class":79},[51,102,39],{"class":83},[51,104,86],{"class":79},[51,106,107],{"class":83},"iskeyword",[51,109,80],{"class":79},[51,111,113],{"class":112},"sjJ54","\"",[51,115,117],{"class":116},"s_sjI","if",[51,119,113],{"class":112},[51,121,122],{"class":79},"))\n",[51,124,126,128,130,132,134,136,138,140,143,145],{"class":53,"line":125},5,[51,127,76],{"class":75},[51,129,80],{"class":79},[51,131,39],{"class":83},[51,133,86],{"class":79},[51,135,107],{"class":83},[51,137,80],{"class":79},[51,139,113],{"class":112},[51,141,142],{"class":116},"name",[51,144,113],{"class":112},[51,146,122],{"class":79},[14,148,149],{},[24,150,151],{},"What this does:",[153,154,155,162,171],"ul",{},[156,157,158,161],"li",{},[37,159,160],{},"keyword.kwlist"," shows all Python keywords",[156,163,164,167,168],{},[37,165,166],{},"keyword.iskeyword(\"if\")"," returns ",[37,169,170],{},"True",[156,172,173,167,176],{},[37,174,175],{},"keyword.iskeyword(\"name\")",[37,177,178],{},"False",[14,180,181],{},"This is useful when you are not sure whether a word is allowed as a variable name.",[29,183,185],{"id":184},"what-python-keywords-are","What Python keywords are",[14,187,188],{},"Keywords are reserved words with special meaning in Python.",[14,190,191],{},"That means:",[153,193,194,201,206],{},[156,195,196,197,200],{},"You ",[24,198,199],{},"cannot"," use them as variable names",[156,202,196,203,205],{},[24,204,199],{}," use them as function names",[156,207,196,208,210],{},[24,209,199],{}," use them as class names",[14,212,213],{},"Examples of Python keywords include:",[153,215,216,220,225,230,235,240,245,250],{},[156,217,218],{},[37,219,117],{},[156,221,222],{},[37,223,224],{},"else",[156,226,227],{},[37,228,229],{},"for",[156,231,232],{},[37,233,234],{},"while",[156,236,237],{},[37,238,239],{},"def",[156,241,242],{},[37,243,244],{},"class",[156,246,247],{},[37,248,249],{},"return",[156,251,252],{},[37,253,58],{},[14,255,256,257,259],{},"For example, this code is invalid because ",[37,258,229],{}," is a keyword:",[42,261,263],{"className":44,"code":262,"language":46,"meta":47,"style":47},"for = 10\n",[37,264,265],{"__ignoreMap":47},[51,266,267,269,272],{"class":53,"line":54},[51,268,229],{"class":57},[51,270,271],{"class":61}," = ",[51,273,275],{"class":274},"srdBf","10\n",[14,277,278,279,281],{},"Python will raise an error because ",[37,280,229],{}," already has a special meaning in the language.",[29,283,285],{"id":284},"why-keywords-matter","Why keywords matter",[14,287,288],{},"Keywords are important because Python uses them to understand how your program is written.",[14,290,291],{},"For example:",[153,293,294,299,304,309],{},[156,295,296,298],{},[37,297,117],{}," starts a condition",[156,300,301,303],{},[37,302,229],{}," starts a loop",[156,305,306,308],{},[37,307,239],{}," starts a function",[156,310,311,313],{},[37,312,249],{}," sends a value back from a function",[14,315,316],{},"If Python sees one of these words, it treats it as part of the language syntax, not as a normal name.",[14,318,319,320,86],{},"Using a keyword incorrectly often causes a syntax error, such as ",[321,322,324],"a",{"href":323},"\u002Ferrors\u002Fsyntaxerror-invalid-syntax-fix\u002F",[37,325,326],{},"SyntaxError: invalid syntax",[14,328,329,330,332,333,335,336,338],{},"Recognizing keywords also helps you read code faster. When you see ",[37,331,117],{},", ",[37,334,229],{},", or ",[37,337,239],{},", you can immediately tell what kind of code block you are looking at.",[29,340,342],{"id":341},"common-python-keywords-beginners-should-know-first","Common Python keywords beginners should know first",[14,344,345],{},"You do not need the full keyword list on day one. These are the most useful ones to learn first.",[347,348,350],"h3",{"id":349},"condition-keywords","Condition keywords",[153,352,353,357,362],{},[156,354,355],{},[37,356,117],{},[156,358,359],{},[37,360,361],{},"elif",[156,363,364],{},[37,365,224],{},[14,367,368,369,86],{},"These are used to make decisions in code. If you are new to conditions, see ",[321,370,372],{"href":371},"\u002Flearn\u002Fpython-if-statements-explained\u002F","Python if statements explained",[347,374,376],{"id":375},"loop-keywords","Loop keywords",[153,378,379,383,387,392,397],{},[156,380,381],{},[37,382,229],{},[156,384,385],{},[37,386,234],{},[156,388,389],{},[37,390,391],{},"break",[156,393,394],{},[37,395,396],{},"continue",[156,398,399],{},[37,400,401],{},"pass",[14,403,404,405,86],{},"These are used for repetition and loop control. To go deeper, read ",[321,406,408],{"href":407},"\u002Flearn\u002Fpython-for-loops-explained\u002F","Python for loops explained",[347,410,412],{"id":411},"function-keywords","Function keywords",[153,414,415,419,423],{},[156,416,417],{},[37,418,239],{},[156,420,421],{},[37,422,249],{},[156,424,425],{},[37,426,427],{},"lambda",[14,429,430,431,86],{},"These are related to functions. If you want the basics first, see ",[321,432,434],{"href":433},"\u002Flearn\u002Fpython-functions-explained\u002F","Python functions explained",[347,436,438],{"id":437},"import-keyword","Import keyword",[153,440,441],{},[156,442,443],{},[37,444,58],{},[14,446,447,448,86],{},"This is used to bring code in from modules. For more on that, see ",[321,449,451],{"href":450},"\u002Flearn\u002Fhow-import-works-in-python\u002F","how import works in Python",[347,453,455],{"id":454},"boolean-and-logic-keywords","Boolean and logic keywords",[153,457,458,462,466,471,476,481],{},[156,459,460],{},[37,461,170],{},[156,463,464],{},[37,465,178],{},[156,467,468],{},[37,469,470],{},"None",[156,472,473],{},[37,474,475],{},"and",[156,477,478],{},[37,479,480],{},"or",[156,482,483],{},[37,484,26],{},[14,486,487],{},"These are used in conditions and logical expressions.",[347,489,491],{"id":490},"exception-handling-keywords","Exception handling keywords",[153,493,494,499,504,509],{},[156,495,496],{},[37,497,498],{},"try",[156,500,501],{},[37,502,503],{},"except",[156,505,506],{},[37,507,508],{},"finally",[156,510,511],{},[37,512,513],{},"raise",[14,515,516],{},"These are used when handling errors in your program.",[29,518,520],{"id":519},"how-keywords-are-different-from-built-in-functions","How keywords are different from built-in functions",[14,522,523],{},"This is a very common beginner confusion.",[347,525,527],{"id":526},"keywords","Keywords",[14,529,530],{},"Keywords are part of Python syntax.",[14,532,533],{},"Examples:",[153,535,536,540,544,548],{},[156,537,538],{},[37,539,117],{},[156,541,542],{},[37,543,229],{},[156,545,546],{},[37,547,239],{},[156,549,550],{},[37,551,249],{},[14,553,554],{},"You do not call a keyword like a function. For example, this is valid syntax:",[42,556,558],{"className":44,"code":557,"language":46,"meta":47,"style":47},"if 5 > 3:\n    print(\"Yes\")\n",[37,559,560,577],{"__ignoreMap":47},[51,561,562,564,567,571,574],{"class":53,"line":54},[51,563,117],{"class":57},[51,565,566],{"class":274}," 5",[51,568,570],{"class":569},"smGrS"," >",[51,572,573],{"class":274}," 3",[51,575,576],{"class":79},":\n",[51,578,579,582,584,586,589,591],{"class":53,"line":65},[51,580,581],{"class":75},"    print",[51,583,80],{"class":79},[51,585,113],{"class":112},[51,587,588],{"class":116},"Yes",[51,590,113],{"class":112},[51,592,93],{"class":79},[14,594,595,596,598],{},"Here, ",[37,597,117],{}," is a keyword. It does not use parentheses as a function call.",[347,600,602],{"id":601},"built-in-functions","Built-in functions",[14,604,605],{},"Built-in functions are names you can call.",[14,607,533],{},[153,609,610,615,620],{},[156,611,612],{},[37,613,614],{},"print()",[156,616,617],{},[37,618,619],{},"len()",[156,621,622],{},[37,623,624],{},"type()",[14,626,627],{},"These use parentheses because you are calling them as functions:",[42,629,631],{"className":44,"code":630,"language":46,"meta":47,"style":47},"print(\"Hello\")\nprint(len(\"Python\"))\n",[37,632,633,648],{"__ignoreMap":47},[51,634,635,637,639,641,644,646],{"class":53,"line":54},[51,636,76],{"class":75},[51,638,80],{"class":79},[51,640,113],{"class":112},[51,642,643],{"class":116},"Hello",[51,645,113],{"class":112},[51,647,93],{"class":79},[51,649,650,652,654,657,659,661,664,666],{"class":53,"line":65},[51,651,76],{"class":75},[51,653,80],{"class":79},[51,655,656],{"class":75},"len",[51,658,80],{"class":79},[51,660,113],{"class":112},[51,662,663],{"class":116},"Python",[51,665,113],{"class":112},[51,667,122],{"class":79},[14,669,670],{},"So:",[153,672,673,678,683],{},[156,674,675,677],{},[37,676,117],{}," is a keyword",[156,679,680,682],{},[37,681,614],{}," is a function",[156,684,685,682],{},[37,686,619],{},[14,688,689,690,694,695,86],{},"If you want to learn more about these, see ",[321,691,693],{"href":692},"\u002Freference\u002Fpython-print-function-explained\u002F","Python print() function explained"," and ",[321,696,698],{"href":697},"\u002Freference\u002Fpython-len-function-explained\u002F","Python len() function explained",[29,700,702],{"id":701},"example-keywords-used-in-real-code","Example: keywords used in real code",[14,704,705],{},"Here is a short program that uses several common keywords:",[42,707,709],{"className":44,"code":708,"language":46,"meta":47,"style":47},"def get_message(number):\n    if number > 0:\n        return \"Positive\"\n    else:\n        return \"Zero or negative\"\n\n\nfor value in [3, 0, -2]:\n    print(get_message(value))\n",[37,710,711,729,745,759,766,777,782,787,820],{"__ignoreMap":47},[51,712,713,716,720,722,726],{"class":53,"line":54},[51,714,239],{"class":715},"sbsja",[51,717,719],{"class":718},"sGLFI"," get_message",[51,721,80],{"class":79},[51,723,725],{"class":724},"sFwrP","number",[51,727,728],{"class":79},"):\n",[51,730,731,734,737,740,743],{"class":53,"line":65},[51,732,733],{"class":57},"    if",[51,735,736],{"class":61}," number ",[51,738,739],{"class":569},">",[51,741,742],{"class":274}," 0",[51,744,576],{"class":79},[51,746,747,750,753,756],{"class":53,"line":72},[51,748,749],{"class":57},"        return",[51,751,752],{"class":112}," \"",[51,754,755],{"class":116},"Positive",[51,757,758],{"class":112},"\"\n",[51,760,761,764],{"class":53,"line":96},[51,762,763],{"class":57},"    else",[51,765,576],{"class":79},[51,767,768,770,772,775],{"class":53,"line":125},[51,769,749],{"class":57},[51,771,752],{"class":112},[51,773,774],{"class":116},"Zero or negative",[51,776,758],{"class":112},[51,778,780],{"class":53,"line":779},6,[51,781,69],{"emptyLinePlaceholder":68},[51,783,785],{"class":53,"line":784},7,[51,786,69],{"emptyLinePlaceholder":68},[51,788,790,792,795,798,801,804,807,809,811,814,817],{"class":53,"line":789},8,[51,791,229],{"class":57},[51,793,794],{"class":61}," value ",[51,796,797],{"class":57},"in",[51,799,800],{"class":79}," [",[51,802,803],{"class":274},"3",[51,805,806],{"class":79},",",[51,808,742],{"class":274},[51,810,806],{"class":79},[51,812,813],{"class":569}," -",[51,815,816],{"class":274},"2",[51,818,819],{"class":79},"]:\n",[51,821,823,825,827,830,832,835],{"class":53,"line":822},9,[51,824,581],{"class":75},[51,826,80],{"class":79},[51,828,829],{"class":83},"get_message",[51,831,80],{"class":79},[51,833,834],{"class":83},"value",[51,836,122],{"class":79},[14,838,839],{},[24,840,841],{},"Output:",[42,843,845],{"className":44,"code":844,"language":46,"meta":47,"style":47},"Positive\nZero or negative\nZero or negative\n",[37,846,847,852,862],{"__ignoreMap":47},[51,848,849],{"class":53,"line":54},[51,850,851],{"class":61},"Positive\n",[51,853,854,857,859],{"class":53,"line":65},[51,855,856],{"class":61},"Zero ",[51,858,480],{"class":569},[51,860,861],{"class":61}," negative\n",[51,863,864,866,868],{"class":53,"line":72},[51,865,856],{"class":61},[51,867,480],{"class":569},[51,869,861],{"class":61},[347,871,873],{"id":872},"keywords-used-here","Keywords used here",[153,875,876,881,886,891,899,904],{},[156,877,878,880],{},[37,879,239],{}," — starts the function definition",[156,882,883,885],{},[37,884,117],{}," — checks a condition",[156,887,888,890],{},[37,889,249],{}," — sends a value back from the function",[156,892,893,895,896,898],{},[37,894,224],{}," — runs when the ",[37,897,117],{}," condition is false",[156,900,901,903],{},[37,902,229],{}," — loops through the list",[156,905,906,908,909,911],{},[37,907,797],{}," — used as part of the ",[37,910,229],{}," loop syntax",[347,913,915],{"id":914},"what-the-code-does","What the code does",[153,917,918,923,926,929],{},[156,919,920,921],{},"It defines a function called ",[37,922,829],{},[156,924,925],{},"The function checks whether a number is greater than zero",[156,927,928],{},"It returns a string based on the result",[156,930,931,932,934],{},"A ",[37,933,229],{}," loop then calls the function for each number in a list",[14,936,937],{},"This is a good example of how keywords help form the structure of Python code.",[14,939,940,941,945],{},"If you want help understanding the bigger picture, ",[321,942,944],{"href":943},"\u002Flearn\u002Fpython-syntax-basics-explained\u002F","Python syntax basics explained"," is a good next step.",[29,947,949],{"id":948},"how-to-see-the-full-keyword-list-in-python","How to see the full keyword list in Python",[14,951,952,953,955],{},"You can use the ",[37,954,39],{}," module from Python’s standard library.",[42,957,959],{"className":44,"code":958,"language":46,"meta":47,"style":47},"import keyword\n\nprint(keyword.kwlist)\n",[37,960,961,967,971],{"__ignoreMap":47},[51,962,963,965],{"class":53,"line":54},[51,964,58],{"class":57},[51,966,62],{"class":61},[51,968,969],{"class":53,"line":65},[51,970,69],{"emptyLinePlaceholder":68},[51,972,973,975,977,979,981,983],{"class":53,"line":72},[51,974,76],{"class":75},[51,976,80],{"class":79},[51,978,39],{"class":83},[51,980,86],{"class":79},[51,982,90],{"class":89},[51,984,93],{"class":79},[14,986,987],{},"This prints the full list of keywords for the version of Python you are using.",[14,989,990],{},"You can also check one word at a time:",[42,992,994],{"className":44,"code":993,"language":46,"meta":47,"style":47},"import keyword\n\nprint(keyword.iskeyword(\"for\"))\nprint(keyword.iskeyword(\"my_variable\"))\n",[37,995,996,1002,1006,1028],{"__ignoreMap":47},[51,997,998,1000],{"class":53,"line":54},[51,999,58],{"class":57},[51,1001,62],{"class":61},[51,1003,1004],{"class":53,"line":65},[51,1005,69],{"emptyLinePlaceholder":68},[51,1007,1008,1010,1012,1014,1016,1018,1020,1022,1024,1026],{"class":53,"line":72},[51,1009,76],{"class":75},[51,1011,80],{"class":79},[51,1013,39],{"class":83},[51,1015,86],{"class":79},[51,1017,107],{"class":83},[51,1019,80],{"class":79},[51,1021,113],{"class":112},[51,1023,229],{"class":116},[51,1025,113],{"class":112},[51,1027,122],{"class":79},[51,1029,1030,1032,1034,1036,1038,1040,1042,1044,1047,1049],{"class":53,"line":96},[51,1031,76],{"class":75},[51,1033,80],{"class":79},[51,1035,39],{"class":83},[51,1037,86],{"class":79},[51,1039,107],{"class":83},[51,1041,80],{"class":79},[51,1043,113],{"class":112},[51,1045,1046],{"class":116},"my_variable",[51,1048,113],{"class":112},[51,1050,122],{"class":79},[14,1052,1053],{},[24,1054,1055],{},"Possible output:",[42,1057,1059],{"className":44,"code":1058,"language":46,"meta":47,"style":47},"True\nFalse\n",[37,1060,1061,1067],{"__ignoreMap":47},[51,1062,1063],{"class":53,"line":54},[51,1064,1066],{"class":1065},"s39Yj","True\n",[51,1068,1069],{"class":53,"line":65},[51,1070,1071],{"class":1065},"False\n",[14,1073,1074],{},"This is useful because keyword lists can change slightly between Python versions.",[14,1076,1077],{},"If you want to run these checks quickly from the command line, you can use:",[42,1079,1083],{"className":1080,"code":1081,"language":1082,"meta":47,"style":47},"language-bash shiki shiki-themes material-theme-lighter github-light github-dark","python -c \"import keyword; print(keyword.kwlist)\"\npython -c \"import keyword; print(keyword.iskeyword('for'))\"\npython -c \"import keyword; print(keyword.iskeyword('my_variable'))\"\n","bash",[37,1084,1085,1101,1114],{"__ignoreMap":47},[51,1086,1087,1090,1094,1096,1099],{"class":53,"line":54},[51,1088,46],{"class":1089},"sbgvK",[51,1091,1093],{"class":1092},"stzsN"," -c",[51,1095,752],{"class":112},[51,1097,1098],{"class":116},"import keyword; print(keyword.kwlist)",[51,1100,758],{"class":112},[51,1102,1103,1105,1107,1109,1112],{"class":53,"line":65},[51,1104,46],{"class":1089},[51,1106,1093],{"class":1092},[51,1108,752],{"class":112},[51,1110,1111],{"class":116},"import keyword; print(keyword.iskeyword('for'))",[51,1113,758],{"class":112},[51,1115,1116,1118,1120,1122,1125],{"class":53,"line":72},[51,1117,46],{"class":1089},[51,1119,1093],{"class":1092},[51,1121,752],{"class":112},[51,1123,1124],{"class":116},"import keyword; print(keyword.iskeyword('my_variable'))",[51,1126,758],{"class":112},[29,1128,1130],{"id":1129},"common-beginner-mistakes-with-keywords","Common beginner mistakes with keywords",[14,1132,1133],{},"Here are some of the most common problems beginners run into.",[347,1135,1137],{"id":1136},"trying-to-use-a-keyword-as-a-variable-name","Trying to use a keyword as a variable name",[14,1139,1140],{},"This will fail:",[42,1142,1144],{"className":44,"code":1143,"language":46,"meta":47,"style":47},"class = \"Beginner\"\n",[37,1145,1146],{"__ignoreMap":47},[51,1147,1148,1150,1153,1155,1158],{"class":53,"line":54},[51,1149,244],{"class":715},[51,1151,1152],{"class":569}," =",[51,1154,752],{"class":112},[51,1156,1157],{"class":116},"Beginner",[51,1159,758],{"class":112},[14,1161,1162],{},"Use a different name instead:",[42,1164,1166],{"className":44,"code":1165,"language":46,"meta":47,"style":47},"class_name = \"Beginner\"\n",[37,1167,1168],{"__ignoreMap":47},[51,1169,1170,1173,1176,1178,1180],{"class":53,"line":54},[51,1171,1172],{"class":61},"class_name ",[51,1174,1175],{"class":569},"=",[51,1177,752],{"class":112},[51,1179,1157],{"class":116},[51,1181,758],{"class":112},[347,1183,1185],{"id":1184},"confusing-keywords-with-built-in-functions","Confusing keywords with built-in functions",[14,1187,1188,1189,694,1191,1193],{},"Many beginners think ",[37,1190,76],{},[37,1192,656],{}," are keywords.",[14,1195,1196],{},"They are not. They are built-in functions.",[14,1198,1199],{},"This matters because:",[153,1201,1202,1205],{},[156,1203,1204],{},"functions are called with parentheses",[156,1206,1207],{},"keywords are part of syntax",[347,1209,1211,1212,332,1214,1216,1217,1219],{"id":1210},"forgetting-that-true-false-and-none-are-special-names","Forgetting that ",[37,1213,170],{},[37,1215,178],{},", and ",[37,1218,470],{}," are special names",[14,1221,1222],{},"These are not ordinary variable names. They have special meaning in Python.",[14,1224,291],{},[42,1226,1228],{"className":44,"code":1227,"language":46,"meta":47,"style":47},"value = True\nempty = None\n",[37,1229,1230,1240],{"__ignoreMap":47},[51,1231,1232,1235,1237],{"class":53,"line":54},[51,1233,1234],{"class":61},"value ",[51,1236,1175],{"class":569},[51,1238,1239],{"class":1065}," True\n",[51,1241,1242,1245,1247],{"class":53,"line":65},[51,1243,1244],{"class":61},"empty ",[51,1246,1175],{"class":569},[51,1248,1249],{"class":1065}," None\n",[14,1251,1252],{},"These names are part of Python itself and should be used as intended.",[347,1254,1256],{"id":1255},"misspelling-a-keyword","Misspelling a keyword",[14,1258,1259],{},"Small spelling mistakes can break your code.",[14,1261,1262],{},"Example:",[42,1264,1266],{"className":44,"code":1265,"language":46,"meta":47,"style":47},"x = 10\n\nelf x > 5:\n    print(\"Big\")\n",[37,1267,1268,1278,1282,1293],{"__ignoreMap":47},[51,1269,1270,1273,1275],{"class":53,"line":54},[51,1271,1272],{"class":61},"x ",[51,1274,1175],{"class":569},[51,1276,1277],{"class":274}," 10\n",[51,1279,1280],{"class":53,"line":65},[51,1281,69],{"emptyLinePlaceholder":68},[51,1283,1284,1287,1289,1291],{"class":53,"line":72},[51,1285,1286],{"class":61},"elf x ",[51,1288,739],{"class":569},[51,1290,566],{"class":274},[51,1292,576],{"class":79},[51,1294,1295,1297,1299,1301,1304,1306],{"class":53,"line":96},[51,1296,581],{"class":75},[51,1298,80],{"class":79},[51,1300,113],{"class":112},[51,1302,1303],{"class":116},"Big",[51,1305,113],{"class":112},[51,1307,93],{"class":79},[14,1309,1310,1311,1314,1315,86],{},"This is invalid because ",[37,1312,1313],{},"elf"," is not the keyword ",[37,1316,361],{},[14,1318,1319],{},"Misspelled keywords may cause:",[153,1321,1322,1325,1328],{},[156,1323,1324],{},"a syntax error",[156,1326,1327],{},"a name error",[156,1329,1330],{},"confusing behavior if you do not notice the typo",[347,1332,1334],{"id":1333},"copying-code-without-understanding-reserved-words","Copying code without understanding reserved words",[14,1336,1337,1338,332,1340,335,1342,1344],{},"It is easy to copy code that uses words like ",[37,1339,498],{},[37,1341,249],{},[37,1343,401],{}," without knowing what they do.",[14,1346,1347],{},"A better approach is to pause and ask:",[153,1349,1350,1353,1356],{},[156,1351,1352],{},"Is this word a keyword?",[156,1354,1355],{},"What role does it play in the code?",[156,1357,1358],{},"Is it starting a block, returning a value, or controlling flow?",[29,1360,1362],{"id":1361},"what-to-learn-next","What to learn next",[14,1364,1365],{},"Once you can recognize Python keywords, the next step is learning how they work together in real syntax.",[14,1367,1368],{},"Good next topics are:",[153,1370,1371,1375,1379,1383,1387],{},[156,1372,1373],{},[321,1374,944],{"href":943},[156,1376,1377],{},[321,1378,372],{"href":371},[156,1380,1381],{},[321,1382,408],{"href":407},[156,1384,1385],{},[321,1386,434],{"href":433},[156,1388,1389],{},[321,1390,1391],{"href":450},"How import works in Python",[14,1393,1394],{},"The goal is not just to spot keywords, but to use them correctly in simple Python programs.",[29,1396,1398],{"id":1397},"faq","FAQ",[347,1400,1402],{"id":1401},"what-is-a-keyword-in-python","What is a keyword in Python?",[14,1404,1405,1406,332,1408,1216,1410,86],{},"A keyword is a reserved word that Python uses as part of its syntax, such as ",[37,1407,117],{},[37,1409,229],{},[37,1411,239],{},[347,1413,1415],{"id":1414},"can-i-use-a-python-keyword-as-a-variable-name","Can I use a Python keyword as a variable name?",[14,1417,1418],{},"No. Keywords are reserved and will cause an error if you try to use them as names.",[347,1420,1422],{"id":1421},"is-print-a-keyword-in-python","Is print a keyword in Python?",[14,1424,1425,1426,1428],{},"No. ",[37,1427,614],{}," is a built-in function, not a keyword.",[347,1430,1432],{"id":1431},"how-do-i-see-all-python-keywords","How do I see all Python keywords?",[14,1434,1435,1436,1438,1439,86],{},"Use the ",[37,1437,39],{}," module and run ",[37,1440,1441],{},"print(keyword.kwlist)",[347,1443,1445],{"id":1444},"do-python-keywords-change","Do Python keywords change?",[14,1447,1448],{},"Sometimes. The list can change slightly between Python versions.",[29,1450,1452],{"id":1451},"see-also","See also",[153,1454,1455,1459,1463,1467,1471,1475,1479,1483],{},[156,1456,1457],{},[321,1458,944],{"href":943},[156,1460,1461],{},[321,1462,372],{"href":371},[156,1464,1465],{},[321,1466,408],{"href":407},[156,1468,1469],{},[321,1470,434],{"href":433},[156,1472,1473],{},[321,1474,1391],{"href":450},[156,1476,1477],{},[321,1478,693],{"href":692},[156,1480,1481],{},[321,1482,698],{"href":697},[156,1484,1485],{},[321,1486,326],{"href":323},[1488,1489,1490],"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 .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}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 pre.shiki code .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}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 .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 .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 .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .stzsN, html code.shiki .stzsN{--shiki-light:#91B859;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":47,"searchDepth":65,"depth":65,"links":1492},[1493,1494,1495,1496,1504,1508,1512,1513,1521,1522,1529],{"id":31,"depth":65,"text":32},{"id":184,"depth":65,"text":185},{"id":284,"depth":65,"text":285},{"id":341,"depth":65,"text":342,"children":1497},[1498,1499,1500,1501,1502,1503],{"id":349,"depth":72,"text":350},{"id":375,"depth":72,"text":376},{"id":411,"depth":72,"text":412},{"id":437,"depth":72,"text":438},{"id":454,"depth":72,"text":455},{"id":490,"depth":72,"text":491},{"id":519,"depth":65,"text":520,"children":1505},[1506,1507],{"id":526,"depth":72,"text":527},{"id":601,"depth":72,"text":602},{"id":701,"depth":65,"text":702,"children":1509},[1510,1511],{"id":872,"depth":72,"text":873},{"id":914,"depth":72,"text":915},{"id":948,"depth":65,"text":949},{"id":1129,"depth":65,"text":1130,"children":1514},[1515,1516,1517,1519,1520],{"id":1136,"depth":72,"text":1137},{"id":1184,"depth":72,"text":1185},{"id":1210,"depth":72,"text":1518},"Forgetting that True, False, and None are special names",{"id":1255,"depth":72,"text":1256},{"id":1333,"depth":72,"text":1334},{"id":1361,"depth":65,"text":1362},{"id":1397,"depth":65,"text":1398,"children":1523},[1524,1525,1526,1527,1528],{"id":1401,"depth":72,"text":1402},{"id":1414,"depth":72,"text":1415},{"id":1421,"depth":72,"text":1422},{"id":1431,"depth":72,"text":1432},{"id":1444,"depth":72,"text":1445},{"id":1451,"depth":65,"text":1452},"Master python keywords explained beginner guide in our comprehensive Python beginner guide.","md",{},"\u002Flearn\u002Fpython-keywords-explained-beginner-guide",{"title":5,"description":1530},"learn\u002Fpython-keywords-explained-beginner-guide","KGyGCDxBZbEaLpefZSty4pWRFWWBp0MM3zT8DrCvkIU",1777585504454]