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