[{"data":1,"prerenderedAt":2185},["ShallowReactive",2],{"doc-\u002Fexamples\u002Fpython-number-guessing-game-example":3},{"id":4,"title":5,"body":6,"description":2178,"extension":2179,"meta":2180,"navigation":56,"path":2181,"seo":2182,"stem":2183,"__hash__":2184},"content\u002Fexamples\u002Fpython-number-guessing-game-example.md","Python Number Guessing Game Example",{"type":7,"value":8,"toc":2144},"minimark",[9,13,17,20,25,28,246,249,311,315,318,334,338,341,356,359,363,366,516,521,532,539,549,553,580,586,600,604,632,635,649,659,663,676,679,689,693,776,779,796,803,807,816,822,831,835,838,852,855,1005,1008,1016,1020,1023,1027,1030,1225,1229,1239,1452,1456,1459,1707,1711,1714,1718,1721,1725,1728,1747,1750,1778,1784,1787,1807,1811,1817,1820,1851,1854,1889,1893,1898,1901,1936,1939,1942,1977,1984,1988,2001,2004,2014,2018,2021,2058,2062,2066,2074,2078,2084,2088,2095,2099,2102,2106,2137,2140],[10,11,5],"h1",{"id":12},"python-number-guessing-game-example",[14,15,16],"p",{},"A number guessing game is a great beginner project because it combines several core Python ideas in one small program.",[14,18,19],{},"In this example, Python picks a random number, asks the user to guess it, and keeps running until the correct answer is entered. The goal here is not just to copy the code, but to understand how each part works.",[21,22,24],"h2",{"id":23},"quick-example","Quick example",[14,26,27],{},"This is the shortest working version:",[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","import random\n\nsecret_number = random.randint(1, 10)\n\nwhile True:\n    guess = int(input(\"Guess a number from 1 to 10: \"))\n\n    if guess == secret_number:\n        print(\"You guessed it!\")\n        break\n    elif guess \u003C secret_number:\n        print(\"Too low\")\n    else:\n        print(\"Too high\")\n","python","",[36,37,38,51,58,95,100,113,146,151,168,185,191,206,222,230],"code",{"__ignoreMap":34},[39,40,43,47],"span",{"class":41,"line":42},"line",1,[39,44,46],{"class":45},"sVHd0","import",[39,48,50],{"class":49},"su5hD"," random\n",[39,52,54],{"class":41,"line":53},2,[39,55,57],{"emptyLinePlaceholder":56},true,"\n",[39,59,61,64,68,71,75,79,82,86,89,92],{"class":41,"line":60},3,[39,62,63],{"class":49},"secret_number ",[39,65,67],{"class":66},"smGrS","=",[39,69,70],{"class":49}," random",[39,72,74],{"class":73},"sP7_E",".",[39,76,78],{"class":77},"slqww","randint",[39,80,81],{"class":73},"(",[39,83,85],{"class":84},"srdBf","1",[39,87,88],{"class":73},",",[39,90,91],{"class":84}," 10",[39,93,94],{"class":73},")\n",[39,96,98],{"class":41,"line":97},4,[39,99,57],{"emptyLinePlaceholder":56},[39,101,103,106,110],{"class":41,"line":102},5,[39,104,105],{"class":45},"while",[39,107,109],{"class":108},"s39Yj"," True",[39,111,112],{"class":73},":\n",[39,114,116,119,121,125,127,131,133,137,141,143],{"class":41,"line":115},6,[39,117,118],{"class":49},"    guess ",[39,120,67],{"class":66},[39,122,124],{"class":123},"sZMiF"," int",[39,126,81],{"class":73},[39,128,130],{"class":129},"sptTA","input",[39,132,81],{"class":73},[39,134,136],{"class":135},"sjJ54","\"",[39,138,140],{"class":139},"s_sjI","Guess a number from 1 to 10: ",[39,142,136],{"class":135},[39,144,145],{"class":73},"))\n",[39,147,149],{"class":41,"line":148},7,[39,150,57],{"emptyLinePlaceholder":56},[39,152,154,157,160,163,166],{"class":41,"line":153},8,[39,155,156],{"class":45},"    if",[39,158,159],{"class":49}," guess ",[39,161,162],{"class":66},"==",[39,164,165],{"class":49}," secret_number",[39,167,112],{"class":73},[39,169,171,174,176,178,181,183],{"class":41,"line":170},9,[39,172,173],{"class":129},"        print",[39,175,81],{"class":73},[39,177,136],{"class":135},[39,179,180],{"class":139},"You guessed it!",[39,182,136],{"class":135},[39,184,94],{"class":73},[39,186,188],{"class":41,"line":187},10,[39,189,190],{"class":45},"        break\n",[39,192,194,197,199,202,204],{"class":41,"line":193},11,[39,195,196],{"class":45},"    elif",[39,198,159],{"class":49},[39,200,201],{"class":66},"\u003C",[39,203,165],{"class":49},[39,205,112],{"class":73},[39,207,209,211,213,215,218,220],{"class":41,"line":208},12,[39,210,173],{"class":129},[39,212,81],{"class":73},[39,214,136],{"class":135},[39,216,217],{"class":139},"Too low",[39,219,136],{"class":135},[39,221,94],{"class":73},[39,223,225,228],{"class":41,"line":224},13,[39,226,227],{"class":45},"    else",[39,229,112],{"class":73},[39,231,233,235,237,239,242,244],{"class":41,"line":232},14,[39,234,173],{"class":129},[39,236,81],{"class":73},[39,238,136],{"class":135},[39,240,241],{"class":139},"Too high",[39,243,136],{"class":135},[39,245,94],{"class":73},[14,247,248],{},"This version uses:",[250,251,252,263,272,281,291,305],"ul",{},[253,254,255,262],"li",{},[256,257,259],"a",{"href":258},"\u002Fstandard-library\u002Frandom.randint-function-explained",[36,260,261],{},"random.randint()"," to choose a secret number",[253,264,265,271],{},[256,266,268],{"href":267},"\u002Freference\u002Fpython-input-function-explained\u002F",[36,269,270],{},"input()"," to get the user's guess",[253,273,274,280],{},[256,275,277],{"href":276},"\u002Freference\u002Fpython-int-function-explained\u002F",[36,278,279],{},"int()"," to turn text into a number",[253,282,283,284,290],{},"a ",[256,285,287,289],{"href":286},"\u002Flearn\u002Fpython-while-loops-explained\u002F",[36,288,105],{}," loop"," to keep asking",[253,292,293,296,297,300,301,304],{},[36,294,295],{},"if",", ",[36,298,299],{},"elif",", and ",[36,302,303],{},"else"," to check the guess",[253,306,307,310],{},[36,308,309],{},"break"," to stop the loop when the user wins",[21,312,314],{"id":313},"what-this-example-teaches","What this example teaches",[14,316,317],{},"This project helps you practice how to:",[250,319,320,323,328,331],{},[253,321,322],{},"combine input, loops, and conditions in one small project",[253,324,325,326],{},"generate a random number with ",[36,327,261],{},[253,329,330],{},"compare a user guess with a secret number",[253,332,333],{},"stop a loop when the correct answer is found",[21,335,337],{"id":336},"how-the-game-works","How the game works",[14,339,340],{},"The program follows a simple pattern:",[342,343,344,347,350,353],"ol",{},[253,345,346],{},"The program picks a random number.",[253,348,349],{},"The user enters a guess.",[253,351,352],{},"The program checks whether the guess is too low, too high, or correct.",[253,354,355],{},"The loop repeats until the user guesses correctly.",[14,357,358],{},"That makes this a good first project because each step is easy to follow.",[21,360,362],{"id":361},"code-walkthrough","Code walkthrough",[14,364,365],{},"Here is the same program again:",[29,367,368],{"className":31,"code":32,"language":33,"meta":34,"style":34},[36,369,370,376,380,402,406,414,436,440,452,466,470,482,496,502],{"__ignoreMap":34},[39,371,372,374],{"class":41,"line":42},[39,373,46],{"class":45},[39,375,50],{"class":49},[39,377,378],{"class":41,"line":53},[39,379,57],{"emptyLinePlaceholder":56},[39,381,382,384,386,388,390,392,394,396,398,400],{"class":41,"line":60},[39,383,63],{"class":49},[39,385,67],{"class":66},[39,387,70],{"class":49},[39,389,74],{"class":73},[39,391,78],{"class":77},[39,393,81],{"class":73},[39,395,85],{"class":84},[39,397,88],{"class":73},[39,399,91],{"class":84},[39,401,94],{"class":73},[39,403,404],{"class":41,"line":97},[39,405,57],{"emptyLinePlaceholder":56},[39,407,408,410,412],{"class":41,"line":102},[39,409,105],{"class":45},[39,411,109],{"class":108},[39,413,112],{"class":73},[39,415,416,418,420,422,424,426,428,430,432,434],{"class":41,"line":115},[39,417,118],{"class":49},[39,419,67],{"class":66},[39,421,124],{"class":123},[39,423,81],{"class":73},[39,425,130],{"class":129},[39,427,81],{"class":73},[39,429,136],{"class":135},[39,431,140],{"class":139},[39,433,136],{"class":135},[39,435,145],{"class":73},[39,437,438],{"class":41,"line":148},[39,439,57],{"emptyLinePlaceholder":56},[39,441,442,444,446,448,450],{"class":41,"line":153},[39,443,156],{"class":45},[39,445,159],{"class":49},[39,447,162],{"class":66},[39,449,165],{"class":49},[39,451,112],{"class":73},[39,453,454,456,458,460,462,464],{"class":41,"line":170},[39,455,173],{"class":129},[39,457,81],{"class":73},[39,459,136],{"class":135},[39,461,180],{"class":139},[39,463,136],{"class":135},[39,465,94],{"class":73},[39,467,468],{"class":41,"line":187},[39,469,190],{"class":45},[39,471,472,474,476,478,480],{"class":41,"line":193},[39,473,196],{"class":45},[39,475,159],{"class":49},[39,477,201],{"class":66},[39,479,165],{"class":49},[39,481,112],{"class":73},[39,483,484,486,488,490,492,494],{"class":41,"line":208},[39,485,173],{"class":129},[39,487,81],{"class":73},[39,489,136],{"class":135},[39,491,217],{"class":139},[39,493,136],{"class":135},[39,495,94],{"class":73},[39,497,498,500],{"class":41,"line":224},[39,499,227],{"class":45},[39,501,112],{"class":73},[39,503,504,506,508,510,512,514],{"class":41,"line":232},[39,505,173],{"class":129},[39,507,81],{"class":73},[39,509,136],{"class":135},[39,511,241],{"class":139},[39,513,136],{"class":135},[39,515,94],{"class":73},[517,518,520],"h3",{"id":519},"import-the-random-module","Import the random module",[29,522,524],{"className":31,"code":523,"language":33,"meta":34,"style":34},"import random\n",[36,525,526],{"__ignoreMap":34},[39,527,528,530],{"class":41,"line":42},[39,529,46],{"class":45},[39,531,50],{"class":49},[14,533,534,535,538],{},"Python needs the ",[36,536,537],{},"random"," module before it can use random number tools.",[14,540,541,542,544,545,74],{},"If you forget this line, the program will fail when it reaches ",[36,543,261],{},". For a broader overview, see the ",[256,546,548],{"href":547},"\u002Fstandard-library\u002Fpython-random-module-overview\u002F","Python random module overview",[517,550,552],{"id":551},"store-the-secret-number-in-a-variable","Store the secret number in a variable",[29,554,556],{"className":31,"code":555,"language":33,"meta":34,"style":34},"secret_number = random.randint(1, 10)\n",[36,557,558],{"__ignoreMap":34},[39,559,560,562,564,566,568,570,572,574,576,578],{"class":41,"line":42},[39,561,63],{"class":49},[39,563,67],{"class":66},[39,565,70],{"class":49},[39,567,74],{"class":73},[39,569,78],{"class":77},[39,571,81],{"class":73},[39,573,85],{"class":84},[39,575,88],{"class":73},[39,577,91],{"class":84},[39,579,94],{"class":73},[14,581,582,583,74],{},"This line creates a random integer from 1 to 10 and stores it in ",[36,584,585],{},"secret_number",[250,587,588,594,597],{},[253,589,590,593],{},[36,591,592],{},"random.randint(1, 10)"," includes both 1 and 10",[253,595,596],{},"the value stays the same for the whole game",[253,598,599],{},"the user does not see this number",[517,601,603],{"id":602},"use-input-to-get-a-guess","Use input() to get a guess",[29,605,607],{"className":31,"code":606,"language":33,"meta":34,"style":34},"guess = int(input(\"Guess a number from 1 to 10: \"))\n",[36,608,609],{"__ignoreMap":34},[39,610,611,614,616,618,620,622,624,626,628,630],{"class":41,"line":42},[39,612,613],{"class":49},"guess ",[39,615,67],{"class":66},[39,617,124],{"class":123},[39,619,81],{"class":73},[39,621,130],{"class":129},[39,623,81],{"class":73},[39,625,136],{"class":135},[39,627,140],{"class":139},[39,629,136],{"class":135},[39,631,145],{"class":73},[14,633,634],{},"This does two things:",[342,636,637,643],{},[253,638,639,642],{},[36,640,641],{},"input(...)"," shows a message and waits for the user to type something",[253,644,645,648],{},[36,646,647],{},"int(...)"," converts that text into a whole number",[14,650,651,652,654,655,74],{},"This matters because ",[36,653,270],{}," always returns text. If you want more help with this step, see ",[256,656,658],{"href":657},"\u002Fhow-to\u002Fhow-to-convert-user-input-to-numbers-in-python\u002F","how to convert user input to numbers in Python",[517,660,662],{"id":661},"use-a-while-loop-to-keep-asking","Use a while loop to keep asking",[29,664,666],{"className":31,"code":665,"language":33,"meta":34,"style":34},"while True:\n",[36,667,668],{"__ignoreMap":34},[39,669,670,672,674],{"class":41,"line":42},[39,671,105],{"class":45},[39,673,109],{"class":108},[39,675,112],{"class":73},[14,677,678],{},"This creates a loop that runs again and again.",[14,680,681,682,685,686,688],{},"Because ",[36,683,684],{},"True"," is always true, the loop keeps going until something stops it. In this program, ",[36,687,309],{}," stops it when the guess is correct.",[517,690,692],{"id":691},"use-if-elif-and-else-to-compare-the-guess","Use if, elif, and else to compare the guess",[29,694,696],{"className":31,"code":695,"language":33,"meta":34,"style":34},"if guess == secret_number:\n    print(\"You guessed it!\")\n    break\nelif guess \u003C secret_number:\n    print(\"Too low\")\nelse:\n    print(\"Too high\")\n",[36,697,698,710,725,730,742,756,762],{"__ignoreMap":34},[39,699,700,702,704,706,708],{"class":41,"line":42},[39,701,295],{"class":45},[39,703,159],{"class":49},[39,705,162],{"class":66},[39,707,165],{"class":49},[39,709,112],{"class":73},[39,711,712,715,717,719,721,723],{"class":41,"line":53},[39,713,714],{"class":129},"    print",[39,716,81],{"class":73},[39,718,136],{"class":135},[39,720,180],{"class":139},[39,722,136],{"class":135},[39,724,94],{"class":73},[39,726,727],{"class":41,"line":60},[39,728,729],{"class":45},"    break\n",[39,731,732,734,736,738,740],{"class":41,"line":97},[39,733,299],{"class":45},[39,735,159],{"class":49},[39,737,201],{"class":66},[39,739,165],{"class":49},[39,741,112],{"class":73},[39,743,744,746,748,750,752,754],{"class":41,"line":102},[39,745,714],{"class":129},[39,747,81],{"class":73},[39,749,136],{"class":135},[39,751,217],{"class":139},[39,753,136],{"class":135},[39,755,94],{"class":73},[39,757,758,760],{"class":41,"line":115},[39,759,303],{"class":45},[39,761,112],{"class":73},[39,763,764,766,768,770,772,774],{"class":41,"line":148},[39,765,714],{"class":129},[39,767,81],{"class":73},[39,769,136],{"class":135},[39,771,241],{"class":139},[39,773,136],{"class":135},[39,775,94],{"class":73},[14,777,778],{},"This comparison block checks three cases:",[250,780,781,784,790],{},[253,782,783],{},"if the guess matches the secret number, the player wins",[253,785,786,787],{},"if the guess is smaller, the program says ",[36,788,789],{},"\"Too low\"",[253,791,792,793],{},"otherwise, the guess must be bigger, so it says ",[36,794,795],{},"\"Too high\"",[14,797,798,799,74],{},"If you want a full beginner explanation of this pattern, see ",[256,800,802],{"href":801},"\u002Flearn\u002Fpython-if-else-and-elif-explained\u002F","Python if, else, and elif explained",[517,804,806],{"id":805},"use-break-to-end-the-loop","Use break to end the loop",[29,808,810],{"className":31,"code":809,"language":33,"meta":34,"style":34},"break\n",[36,811,812],{"__ignoreMap":34},[39,813,814],{"class":41,"line":42},[39,815,809],{"class":45},[14,817,818,819,821],{},"Without ",[36,820,309],{},", the loop would continue forever, even after the correct guess.",[14,823,824,825,827,828,830],{},"That is why ",[36,826,309],{}," must be inside the correct ",[36,829,295],{}," block.",[21,832,834],{"id":833},"beginner-version-to-show-first","Beginner version to show first",[14,836,837],{},"When you build your first guessing game, keep it simple:",[250,839,840,843,846,849],{},[253,841,842],{},"use a small range such as 1 to 10",[253,844,845],{},"use one loop and one comparison block",[253,847,848],{},"avoid advanced features like functions at first",[253,850,851],{},"test the program after every small change",[14,853,854],{},"Here is a beginner-friendly version again:",[29,856,857],{"className":31,"code":32,"language":33,"meta":34,"style":34},[36,858,859,865,869,891,895,903,925,929,941,955,959,971,985,991],{"__ignoreMap":34},[39,860,861,863],{"class":41,"line":42},[39,862,46],{"class":45},[39,864,50],{"class":49},[39,866,867],{"class":41,"line":53},[39,868,57],{"emptyLinePlaceholder":56},[39,870,871,873,875,877,879,881,883,885,887,889],{"class":41,"line":60},[39,872,63],{"class":49},[39,874,67],{"class":66},[39,876,70],{"class":49},[39,878,74],{"class":73},[39,880,78],{"class":77},[39,882,81],{"class":73},[39,884,85],{"class":84},[39,886,88],{"class":73},[39,888,91],{"class":84},[39,890,94],{"class":73},[39,892,893],{"class":41,"line":97},[39,894,57],{"emptyLinePlaceholder":56},[39,896,897,899,901],{"class":41,"line":102},[39,898,105],{"class":45},[39,900,109],{"class":108},[39,902,112],{"class":73},[39,904,905,907,909,911,913,915,917,919,921,923],{"class":41,"line":115},[39,906,118],{"class":49},[39,908,67],{"class":66},[39,910,124],{"class":123},[39,912,81],{"class":73},[39,914,130],{"class":129},[39,916,81],{"class":73},[39,918,136],{"class":135},[39,920,140],{"class":139},[39,922,136],{"class":135},[39,924,145],{"class":73},[39,926,927],{"class":41,"line":148},[39,928,57],{"emptyLinePlaceholder":56},[39,930,931,933,935,937,939],{"class":41,"line":153},[39,932,156],{"class":45},[39,934,159],{"class":49},[39,936,162],{"class":66},[39,938,165],{"class":49},[39,940,112],{"class":73},[39,942,943,945,947,949,951,953],{"class":41,"line":170},[39,944,173],{"class":129},[39,946,81],{"class":73},[39,948,136],{"class":135},[39,950,180],{"class":139},[39,952,136],{"class":135},[39,954,94],{"class":73},[39,956,957],{"class":41,"line":187},[39,958,190],{"class":45},[39,960,961,963,965,967,969],{"class":41,"line":193},[39,962,196],{"class":45},[39,964,159],{"class":49},[39,966,201],{"class":66},[39,968,165],{"class":49},[39,970,112],{"class":73},[39,972,973,975,977,979,981,983],{"class":41,"line":208},[39,974,173],{"class":129},[39,976,81],{"class":73},[39,978,136],{"class":135},[39,980,217],{"class":139},[39,982,136],{"class":135},[39,984,94],{"class":73},[39,986,987,989],{"class":41,"line":224},[39,988,227],{"class":45},[39,990,112],{"class":73},[39,992,993,995,997,999,1001,1003],{"class":41,"line":232},[39,994,173],{"class":129},[39,996,81],{"class":73},[39,998,136],{"class":135},[39,1000,241],{"class":139},[39,1002,136],{"class":135},[39,1004,94],{"class":73},[14,1006,1007],{},"Example run:",[29,1009,1014],{"className":1010,"code":1012,"language":1013,"meta":34},[1011],"language-text","Guess a number from 1 to 10: 4\nToo low\nGuess a number from 1 to 10: 8\nToo high\nGuess a number from 1 to 10: 6\nYou guessed it!\n","text",[36,1015,1012],{"__ignoreMap":34},[21,1017,1019],{"id":1018},"useful-improvements","Useful improvements",[14,1021,1022],{},"Once the basic game works, you can improve it in small steps.",[517,1024,1026],{"id":1025},"count-the-number-of-guesses","Count the number of guesses",[14,1028,1029],{},"This version tracks how many times the user guessed:",[29,1031,1033],{"className":31,"code":1032,"language":33,"meta":34,"style":34},"import random\n\nsecret_number = random.randint(1, 10)\nguess_count = 0\n\nwhile True:\n    guess = int(input(\"Guess a number from 1 to 10: \"))\n    guess_count += 1\n\n    if guess == secret_number:\n        print(\"You guessed it!\")\n        print(\"Guesses:\", guess_count)\n        break\n    elif guess \u003C secret_number:\n        print(\"Too low\")\n    else:\n        print(\"Too high\")\n",[36,1034,1035,1041,1045,1067,1077,1081,1089,1111,1122,1126,1138,1152,1172,1176,1188,1203,1210],{"__ignoreMap":34},[39,1036,1037,1039],{"class":41,"line":42},[39,1038,46],{"class":45},[39,1040,50],{"class":49},[39,1042,1043],{"class":41,"line":53},[39,1044,57],{"emptyLinePlaceholder":56},[39,1046,1047,1049,1051,1053,1055,1057,1059,1061,1063,1065],{"class":41,"line":60},[39,1048,63],{"class":49},[39,1050,67],{"class":66},[39,1052,70],{"class":49},[39,1054,74],{"class":73},[39,1056,78],{"class":77},[39,1058,81],{"class":73},[39,1060,85],{"class":84},[39,1062,88],{"class":73},[39,1064,91],{"class":84},[39,1066,94],{"class":73},[39,1068,1069,1072,1074],{"class":41,"line":97},[39,1070,1071],{"class":49},"guess_count ",[39,1073,67],{"class":66},[39,1075,1076],{"class":84}," 0\n",[39,1078,1079],{"class":41,"line":102},[39,1080,57],{"emptyLinePlaceholder":56},[39,1082,1083,1085,1087],{"class":41,"line":115},[39,1084,105],{"class":45},[39,1086,109],{"class":108},[39,1088,112],{"class":73},[39,1090,1091,1093,1095,1097,1099,1101,1103,1105,1107,1109],{"class":41,"line":148},[39,1092,118],{"class":49},[39,1094,67],{"class":66},[39,1096,124],{"class":123},[39,1098,81],{"class":73},[39,1100,130],{"class":129},[39,1102,81],{"class":73},[39,1104,136],{"class":135},[39,1106,140],{"class":139},[39,1108,136],{"class":135},[39,1110,145],{"class":73},[39,1112,1113,1116,1119],{"class":41,"line":153},[39,1114,1115],{"class":49},"    guess_count ",[39,1117,1118],{"class":66},"+=",[39,1120,1121],{"class":84}," 1\n",[39,1123,1124],{"class":41,"line":170},[39,1125,57],{"emptyLinePlaceholder":56},[39,1127,1128,1130,1132,1134,1136],{"class":41,"line":187},[39,1129,156],{"class":45},[39,1131,159],{"class":49},[39,1133,162],{"class":66},[39,1135,165],{"class":49},[39,1137,112],{"class":73},[39,1139,1140,1142,1144,1146,1148,1150],{"class":41,"line":193},[39,1141,173],{"class":129},[39,1143,81],{"class":73},[39,1145,136],{"class":135},[39,1147,180],{"class":139},[39,1149,136],{"class":135},[39,1151,94],{"class":73},[39,1153,1154,1156,1158,1160,1163,1165,1167,1170],{"class":41,"line":208},[39,1155,173],{"class":129},[39,1157,81],{"class":73},[39,1159,136],{"class":135},[39,1161,1162],{"class":139},"Guesses:",[39,1164,136],{"class":135},[39,1166,88],{"class":73},[39,1168,1169],{"class":77}," guess_count",[39,1171,94],{"class":73},[39,1173,1174],{"class":41,"line":224},[39,1175,190],{"class":45},[39,1177,1178,1180,1182,1184,1186],{"class":41,"line":232},[39,1179,196],{"class":45},[39,1181,159],{"class":49},[39,1183,201],{"class":66},[39,1185,165],{"class":49},[39,1187,112],{"class":73},[39,1189,1191,1193,1195,1197,1199,1201],{"class":41,"line":1190},15,[39,1192,173],{"class":129},[39,1194,81],{"class":73},[39,1196,136],{"class":135},[39,1198,217],{"class":139},[39,1200,136],{"class":135},[39,1202,94],{"class":73},[39,1204,1206,1208],{"class":41,"line":1205},16,[39,1207,227],{"class":45},[39,1209,112],{"class":73},[39,1211,1213,1215,1217,1219,1221,1223],{"class":41,"line":1212},17,[39,1214,173],{"class":129},[39,1216,81],{"class":73},[39,1218,136],{"class":135},[39,1220,241],{"class":139},[39,1222,136],{"class":135},[39,1224,94],{"class":73},[517,1226,1228],{"id":1227},"validate-input-to-avoid-crashes","Validate input to avoid crashes",[14,1230,1231,1232,1234,1235,1238],{},"If the user types letters, ",[36,1233,279],{}," raises a ",[36,1236,1237],{},"ValueError",". This safer version checks the input first:",[29,1240,1242],{"className":31,"code":1241,"language":33,"meta":34,"style":34},"import random\n\nsecret_number = random.randint(1, 10)\n\nwhile True:\n    user_text = input(\"Guess a number from 1 to 10: \")\n\n    if not user_text.isdigit():\n        print(\"Please enter a whole number.\")\n        continue\n\n    guess = int(user_text)\n\n    if guess == secret_number:\n        print(\"You guessed it!\")\n        break\n    elif guess \u003C secret_number:\n        print(\"Too low\")\n    else:\n        print(\"Too high\")\n",[36,1243,1244,1250,1254,1276,1280,1288,1308,1312,1330,1345,1350,1354,1369,1373,1385,1399,1403,1415,1430,1437],{"__ignoreMap":34},[39,1245,1246,1248],{"class":41,"line":42},[39,1247,46],{"class":45},[39,1249,50],{"class":49},[39,1251,1252],{"class":41,"line":53},[39,1253,57],{"emptyLinePlaceholder":56},[39,1255,1256,1258,1260,1262,1264,1266,1268,1270,1272,1274],{"class":41,"line":60},[39,1257,63],{"class":49},[39,1259,67],{"class":66},[39,1261,70],{"class":49},[39,1263,74],{"class":73},[39,1265,78],{"class":77},[39,1267,81],{"class":73},[39,1269,85],{"class":84},[39,1271,88],{"class":73},[39,1273,91],{"class":84},[39,1275,94],{"class":73},[39,1277,1278],{"class":41,"line":97},[39,1279,57],{"emptyLinePlaceholder":56},[39,1281,1282,1284,1286],{"class":41,"line":102},[39,1283,105],{"class":45},[39,1285,109],{"class":108},[39,1287,112],{"class":73},[39,1289,1290,1293,1295,1298,1300,1302,1304,1306],{"class":41,"line":115},[39,1291,1292],{"class":49},"    user_text ",[39,1294,67],{"class":66},[39,1296,1297],{"class":129}," input",[39,1299,81],{"class":73},[39,1301,136],{"class":135},[39,1303,140],{"class":139},[39,1305,136],{"class":135},[39,1307,94],{"class":73},[39,1309,1310],{"class":41,"line":148},[39,1311,57],{"emptyLinePlaceholder":56},[39,1313,1314,1316,1319,1322,1324,1327],{"class":41,"line":153},[39,1315,156],{"class":45},[39,1317,1318],{"class":66}," not",[39,1320,1321],{"class":49}," user_text",[39,1323,74],{"class":73},[39,1325,1326],{"class":77},"isdigit",[39,1328,1329],{"class":73},"():\n",[39,1331,1332,1334,1336,1338,1341,1343],{"class":41,"line":170},[39,1333,173],{"class":129},[39,1335,81],{"class":73},[39,1337,136],{"class":135},[39,1339,1340],{"class":139},"Please enter a whole number.",[39,1342,136],{"class":135},[39,1344,94],{"class":73},[39,1346,1347],{"class":41,"line":187},[39,1348,1349],{"class":45},"        continue\n",[39,1351,1352],{"class":41,"line":193},[39,1353,57],{"emptyLinePlaceholder":56},[39,1355,1356,1358,1360,1362,1364,1367],{"class":41,"line":208},[39,1357,118],{"class":49},[39,1359,67],{"class":66},[39,1361,124],{"class":123},[39,1363,81],{"class":73},[39,1365,1366],{"class":77},"user_text",[39,1368,94],{"class":73},[39,1370,1371],{"class":41,"line":224},[39,1372,57],{"emptyLinePlaceholder":56},[39,1374,1375,1377,1379,1381,1383],{"class":41,"line":232},[39,1376,156],{"class":45},[39,1378,159],{"class":49},[39,1380,162],{"class":66},[39,1382,165],{"class":49},[39,1384,112],{"class":73},[39,1386,1387,1389,1391,1393,1395,1397],{"class":41,"line":1190},[39,1388,173],{"class":129},[39,1390,81],{"class":73},[39,1392,136],{"class":135},[39,1394,180],{"class":139},[39,1396,136],{"class":135},[39,1398,94],{"class":73},[39,1400,1401],{"class":41,"line":1205},[39,1402,190],{"class":45},[39,1404,1405,1407,1409,1411,1413],{"class":41,"line":1212},[39,1406,196],{"class":45},[39,1408,159],{"class":49},[39,1410,201],{"class":66},[39,1412,165],{"class":49},[39,1414,112],{"class":73},[39,1416,1418,1420,1422,1424,1426,1428],{"class":41,"line":1417},18,[39,1419,173],{"class":129},[39,1421,81],{"class":73},[39,1423,136],{"class":135},[39,1425,217],{"class":139},[39,1427,136],{"class":135},[39,1429,94],{"class":73},[39,1431,1433,1435],{"class":41,"line":1432},19,[39,1434,227],{"class":45},[39,1436,112],{"class":73},[39,1438,1440,1442,1444,1446,1448,1450],{"class":41,"line":1439},20,[39,1441,173],{"class":129},[39,1443,81],{"class":73},[39,1445,136],{"class":135},[39,1447,241],{"class":139},[39,1449,136],{"class":135},[39,1451,94],{"class":73},[517,1453,1455],{"id":1454},"limit-the-number-of-attempts","Limit the number of attempts",[14,1457,1458],{},"You can also stop the game after a fixed number of guesses:",[29,1460,1462],{"className":31,"code":1461,"language":33,"meta":34,"style":34},"import random\n\nsecret_number = random.randint(1, 10)\nattempts_left = 3\n\nwhile attempts_left > 0:\n    guess = int(input(\"Guess a number from 1 to 10: \"))\n\n    if guess == secret_number:\n        print(\"You guessed it!\")\n        break\n    elif guess \u003C secret_number:\n        print(\"Too low\")\n    else:\n        print(\"Too high\")\n\n    attempts_left -= 1\n    print(\"Attempts left:\", attempts_left)\n\nif attempts_left == 0 and guess != secret_number:\n    print(\"Game over. The number was\", secret_number)\n",[36,1463,1464,1470,1474,1496,1506,1510,1525,1547,1551,1563,1577,1581,1593,1607,1613,1627,1631,1641,1661,1665,1687],{"__ignoreMap":34},[39,1465,1466,1468],{"class":41,"line":42},[39,1467,46],{"class":45},[39,1469,50],{"class":49},[39,1471,1472],{"class":41,"line":53},[39,1473,57],{"emptyLinePlaceholder":56},[39,1475,1476,1478,1480,1482,1484,1486,1488,1490,1492,1494],{"class":41,"line":60},[39,1477,63],{"class":49},[39,1479,67],{"class":66},[39,1481,70],{"class":49},[39,1483,74],{"class":73},[39,1485,78],{"class":77},[39,1487,81],{"class":73},[39,1489,85],{"class":84},[39,1491,88],{"class":73},[39,1493,91],{"class":84},[39,1495,94],{"class":73},[39,1497,1498,1501,1503],{"class":41,"line":97},[39,1499,1500],{"class":49},"attempts_left ",[39,1502,67],{"class":66},[39,1504,1505],{"class":84}," 3\n",[39,1507,1508],{"class":41,"line":102},[39,1509,57],{"emptyLinePlaceholder":56},[39,1511,1512,1514,1517,1520,1523],{"class":41,"line":115},[39,1513,105],{"class":45},[39,1515,1516],{"class":49}," attempts_left ",[39,1518,1519],{"class":66},">",[39,1521,1522],{"class":84}," 0",[39,1524,112],{"class":73},[39,1526,1527,1529,1531,1533,1535,1537,1539,1541,1543,1545],{"class":41,"line":148},[39,1528,118],{"class":49},[39,1530,67],{"class":66},[39,1532,124],{"class":123},[39,1534,81],{"class":73},[39,1536,130],{"class":129},[39,1538,81],{"class":73},[39,1540,136],{"class":135},[39,1542,140],{"class":139},[39,1544,136],{"class":135},[39,1546,145],{"class":73},[39,1548,1549],{"class":41,"line":153},[39,1550,57],{"emptyLinePlaceholder":56},[39,1552,1553,1555,1557,1559,1561],{"class":41,"line":170},[39,1554,156],{"class":45},[39,1556,159],{"class":49},[39,1558,162],{"class":66},[39,1560,165],{"class":49},[39,1562,112],{"class":73},[39,1564,1565,1567,1569,1571,1573,1575],{"class":41,"line":187},[39,1566,173],{"class":129},[39,1568,81],{"class":73},[39,1570,136],{"class":135},[39,1572,180],{"class":139},[39,1574,136],{"class":135},[39,1576,94],{"class":73},[39,1578,1579],{"class":41,"line":193},[39,1580,190],{"class":45},[39,1582,1583,1585,1587,1589,1591],{"class":41,"line":208},[39,1584,196],{"class":45},[39,1586,159],{"class":49},[39,1588,201],{"class":66},[39,1590,165],{"class":49},[39,1592,112],{"class":73},[39,1594,1595,1597,1599,1601,1603,1605],{"class":41,"line":224},[39,1596,173],{"class":129},[39,1598,81],{"class":73},[39,1600,136],{"class":135},[39,1602,217],{"class":139},[39,1604,136],{"class":135},[39,1606,94],{"class":73},[39,1608,1609,1611],{"class":41,"line":232},[39,1610,227],{"class":45},[39,1612,112],{"class":73},[39,1614,1615,1617,1619,1621,1623,1625],{"class":41,"line":1190},[39,1616,173],{"class":129},[39,1618,81],{"class":73},[39,1620,136],{"class":135},[39,1622,241],{"class":139},[39,1624,136],{"class":135},[39,1626,94],{"class":73},[39,1628,1629],{"class":41,"line":1205},[39,1630,57],{"emptyLinePlaceholder":56},[39,1632,1633,1636,1639],{"class":41,"line":1212},[39,1634,1635],{"class":49},"    attempts_left ",[39,1637,1638],{"class":66},"-=",[39,1640,1121],{"class":84},[39,1642,1643,1645,1647,1649,1652,1654,1656,1659],{"class":41,"line":1417},[39,1644,714],{"class":129},[39,1646,81],{"class":73},[39,1648,136],{"class":135},[39,1650,1651],{"class":139},"Attempts left:",[39,1653,136],{"class":135},[39,1655,88],{"class":73},[39,1657,1658],{"class":77}," attempts_left",[39,1660,94],{"class":73},[39,1662,1663],{"class":41,"line":1432},[39,1664,57],{"emptyLinePlaceholder":56},[39,1666,1667,1669,1671,1673,1675,1678,1680,1683,1685],{"class":41,"line":1439},[39,1668,295],{"class":45},[39,1670,1516],{"class":49},[39,1672,162],{"class":66},[39,1674,1522],{"class":84},[39,1676,1677],{"class":66}," and",[39,1679,159],{"class":49},[39,1681,1682],{"class":66},"!=",[39,1684,165],{"class":49},[39,1686,112],{"class":73},[39,1688,1690,1692,1694,1696,1699,1701,1703,1705],{"class":41,"line":1689},21,[39,1691,714],{"class":129},[39,1693,81],{"class":73},[39,1695,136],{"class":135},[39,1697,1698],{"class":139},"Game over. The number was",[39,1700,136],{"class":135},[39,1702,88],{"class":73},[39,1704,165],{"class":77},[39,1706,94],{"class":73},[517,1708,1710],{"id":1709},"let-the-user-play-again","Let the user play again",[14,1712,1713],{},"A good next step is wrapping the game in another loop so the user can start a new round after winning.",[21,1715,1717],{"id":1716},"common-problems-in-this-project","Common problems in this project",[14,1719,1720],{},"Here are the most common beginner mistakes in a guessing game.",[517,1722,1724],{"id":1723},"valueerror-when-converting-input","ValueError when converting input",[14,1726,1727],{},"Problem:",[250,1729,1730,1736,1742],{},[253,1731,1732,1733],{},"you type letters like ",[36,1734,1735],{},"hello",[253,1737,1738,1739,1741],{},"the program uses ",[36,1740,279],{}," on that text",[253,1743,1744,1745],{},"Python crashes with ",[36,1746,1237],{},[14,1748,1749],{},"Example:",[29,1751,1753],{"className":31,"code":1752,"language":33,"meta":34,"style":34},"guess = int(input(\"Guess a number: \"))\n",[36,1754,1755],{"__ignoreMap":34},[39,1756,1757,1759,1761,1763,1765,1767,1769,1771,1774,1776],{"class":41,"line":42},[39,1758,613],{"class":49},[39,1760,67],{"class":66},[39,1762,124],{"class":123},[39,1764,81],{"class":73},[39,1766,130],{"class":129},[39,1768,81],{"class":73},[39,1770,136],{"class":135},[39,1772,1773],{"class":139},"Guess a number: ",[39,1775,136],{"class":135},[39,1777,145],{"class":73},[14,1779,1780,1781,1783],{},"If the user enters ",[36,1782,1735],{},", this line fails.",[14,1785,1786],{},"Fixes:",[250,1788,1789,1795,1800],{},[253,1790,1791,1792],{},"only enter number text such as ",[36,1793,1794],{},"5",[253,1796,1797,1798],{},"validate the input before calling ",[36,1799,279],{},[253,1801,1802,1803],{},"read ",[256,1804,1806],{"href":1805},"\u002Ferrors\u002Fvalueerror-invalid-literal-for-int-with-base-10-fix\u002F","ValueError: invalid literal for int() with base 10",[517,1808,1810],{"id":1809},"infinite-loop-because-break-is-missing","Infinite loop because break is missing",[14,1812,1813,1814,1816],{},"If ",[36,1815,309],{}," is missing, the loop never ends after the correct answer.",[14,1818,1819],{},"Wrong idea:",[29,1821,1823],{"className":31,"code":1822,"language":33,"meta":34,"style":34},"if guess == secret_number:\n    print(\"You guessed it!\")\n",[36,1824,1825,1837],{"__ignoreMap":34},[39,1826,1827,1829,1831,1833,1835],{"class":41,"line":42},[39,1828,295],{"class":45},[39,1830,159],{"class":49},[39,1832,162],{"class":66},[39,1834,165],{"class":49},[39,1836,112],{"class":73},[39,1838,1839,1841,1843,1845,1847,1849],{"class":41,"line":53},[39,1840,714],{"class":129},[39,1842,81],{"class":73},[39,1844,136],{"class":135},[39,1846,180],{"class":139},[39,1848,136],{"class":135},[39,1850,94],{"class":73},[14,1852,1853],{},"Better:",[29,1855,1857],{"className":31,"code":1856,"language":33,"meta":34,"style":34},"if guess == secret_number:\n    print(\"You guessed it!\")\n    break\n",[36,1858,1859,1871,1885],{"__ignoreMap":34},[39,1860,1861,1863,1865,1867,1869],{"class":41,"line":42},[39,1862,295],{"class":45},[39,1864,159],{"class":49},[39,1866,162],{"class":66},[39,1868,165],{"class":49},[39,1870,112],{"class":73},[39,1872,1873,1875,1877,1879,1881,1883],{"class":41,"line":53},[39,1874,714],{"class":129},[39,1876,81],{"class":73},[39,1878,136],{"class":135},[39,1880,180],{"class":139},[39,1882,136],{"class":135},[39,1884,94],{"class":73},[39,1886,1887],{"class":41,"line":60},[39,1888,729],{"class":45},[517,1890,1892],{"id":1891},"wrong-indentation","Wrong indentation",[14,1894,1895,1896,830],{},"Indentation controls which lines belong inside the loop or inside an ",[36,1897,295],{},[14,1899,1900],{},"For example, this is wrong:",[29,1902,1904],{"className":31,"code":1903,"language":33,"meta":34,"style":34},"while True:\nguess = int(input(\"Guess a number: \"))\n",[36,1905,1906,1914],{"__ignoreMap":34},[39,1907,1908,1910,1912],{"class":41,"line":42},[39,1909,105],{"class":45},[39,1911,109],{"class":108},[39,1913,112],{"class":73},[39,1915,1916,1918,1920,1922,1924,1926,1928,1930,1932,1934],{"class":41,"line":53},[39,1917,613],{"class":49},[39,1919,67],{"class":66},[39,1921,124],{"class":123},[39,1923,81],{"class":73},[39,1925,130],{"class":129},[39,1927,81],{"class":73},[39,1929,136],{"class":135},[39,1931,1773],{"class":139},[39,1933,136],{"class":135},[39,1935,145],{"class":73},[14,1937,1938],{},"Python expects the loop body to be indented.",[14,1940,1941],{},"Correct version:",[29,1943,1945],{"className":31,"code":1944,"language":33,"meta":34,"style":34},"while True:\n    guess = int(input(\"Guess a number: \"))\n",[36,1946,1947,1955],{"__ignoreMap":34},[39,1948,1949,1951,1953],{"class":41,"line":42},[39,1950,105],{"class":45},[39,1952,109],{"class":108},[39,1954,112],{"class":73},[39,1956,1957,1959,1961,1963,1965,1967,1969,1971,1973,1975],{"class":41,"line":53},[39,1958,118],{"class":49},[39,1960,67],{"class":66},[39,1962,124],{"class":123},[39,1964,81],{"class":73},[39,1966,130],{"class":129},[39,1968,81],{"class":73},[39,1970,136],{"class":135},[39,1972,1773],{"class":139},[39,1974,136],{"class":135},[39,1976,145],{"class":73},[14,1978,1979,1980,74],{},"If you see this kind of problem, read ",[256,1981,1983],{"href":1982},"\u002Ferrors\u002Findentationerror-expected-an-indented-block-fix\u002F","IndentationError: expected an indented block",[517,1985,1987],{"id":1986},"forgetting-to-import-random","Forgetting to import random",[14,1989,1990,1991,1993,1994,1997,1998,2000],{},"If you use ",[36,1992,261],{}," without ",[36,1995,1996],{},"import random",", Python does not know what ",[36,1999,537],{}," means.",[14,2002,2003],{},"Always include:",[29,2005,2006],{"className":31,"code":523,"language":33,"meta":34,"style":34},[36,2007,2008],{"__ignoreMap":34},[39,2009,2010,2012],{"class":41,"line":42},[39,2011,46],{"class":45},[39,2013,50],{"class":49},[517,2015,2017],{"id":2016},"other-common-causes","Other common causes",[14,2019,2020],{},"These mistakes also happen often:",[250,2022,2023,2032,2038,2047,2055],{},[253,2024,2025,2026,2028,2029,2031],{},"using ",[36,2027,270],{}," without converting the result to ",[36,2030,279],{}," before comparing with a number",[253,2033,2034,2035,2037],{},"typing words like ",[36,2036,1735],{}," when the program expects a number",[253,2039,2040,2041,2043,2044,2046],{},"placing ",[36,2042,309],{}," outside the correct ",[36,2045,295],{}," block",[253,2048,2049,2050,2052,2053],{},"misspelling ",[36,2051,78],{}," or ",[36,2054,537],{},[253,2056,2057],{},"using incorrect indentation in the loop",[21,2059,2061],{"id":2060},"faq","FAQ",[517,2063,2065],{"id":2064},"why-does-input-need-int-here","Why does input() need int() here?",[14,2067,2068,2070,2071,2073],{},[36,2069,270],{}," returns text. ",[36,2072,279],{}," changes that text into a number so it can be compared with the secret number.",[517,2075,2077],{"id":2076},"why-use-a-while-loop-in-a-guessing-game","Why use a while loop in a guessing game?",[14,2079,2080,2081,2083],{},"A ",[36,2082,105],{}," loop lets the program keep asking until the correct guess is entered.",[517,2085,2087],{"id":2086},"why-does-my-program-crash-when-i-enter-letters","Why does my program crash when I enter letters?",[14,2089,2090,2092,2093,74],{},[36,2091,279],{}," can only convert valid number text. If the user types letters, Python raises a ",[36,2094,1237],{},[517,2096,2098],{"id":2097},"can-i-make-the-game-harder","Can I make the game harder?",[14,2100,2101],{},"Yes. Increase the number range, limit attempts, or add hints.",[21,2103,2105],{"id":2104},"see-also","See also",[250,2107,2108,2112,2117,2122,2127,2132],{},[253,2109,2110],{},[256,2111,548],{"href":547},[253,2113,2114],{},[256,2115,2116],{"href":258},"random.randint() function explained",[253,2118,2119],{},[256,2120,2121],{"href":267},"Python input() function explained",[253,2123,2124],{},[256,2125,2126],{"href":276},"Python int() function explained",[253,2128,2129],{},[256,2130,2131],{"href":286},"Python while loops explained",[253,2133,2134],{},[256,2135,2136],{"href":657},"How to convert user input to numbers in Python",[14,2138,2139],{},"Build the basic game first and make sure you understand every line. After that, improve it by adding input validation and a guess counter.",[2141,2142,2143],"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 .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}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 .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}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 .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);}",{"title":34,"searchDepth":53,"depth":53,"links":2145},[2146,2147,2148,2149,2157,2158,2164,2171,2177],{"id":23,"depth":53,"text":24},{"id":313,"depth":53,"text":314},{"id":336,"depth":53,"text":337},{"id":361,"depth":53,"text":362,"children":2150},[2151,2152,2153,2154,2155,2156],{"id":519,"depth":60,"text":520},{"id":551,"depth":60,"text":552},{"id":602,"depth":60,"text":603},{"id":661,"depth":60,"text":662},{"id":691,"depth":60,"text":692},{"id":805,"depth":60,"text":806},{"id":833,"depth":53,"text":834},{"id":1018,"depth":53,"text":1019,"children":2159},[2160,2161,2162,2163],{"id":1025,"depth":60,"text":1026},{"id":1227,"depth":60,"text":1228},{"id":1454,"depth":60,"text":1455},{"id":1709,"depth":60,"text":1710},{"id":1716,"depth":53,"text":1717,"children":2165},[2166,2167,2168,2169,2170],{"id":1723,"depth":60,"text":1724},{"id":1809,"depth":60,"text":1810},{"id":1891,"depth":60,"text":1892},{"id":1986,"depth":60,"text":1987},{"id":2016,"depth":60,"text":2017},{"id":2060,"depth":53,"text":2061,"children":2172},[2173,2174,2175,2176],{"id":2064,"depth":60,"text":2065},{"id":2076,"depth":60,"text":2077},{"id":2086,"depth":60,"text":2087},{"id":2097,"depth":60,"text":2098},{"id":2104,"depth":53,"text":2105},"Master python number guessing game example in our comprehensive Python beginner guide.","md",{},"\u002Fexamples\u002Fpython-number-guessing-game-example",{"title":5,"description":2178},"examples\u002Fpython-number-guessing-game-example","TmyiqGTPESDCbTGaeblB9b5ruZuhQZFdhZnXz2lByAU",1777585508948]