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