[{"data":1,"prerenderedAt":1480},["ShallowReactive",2],{"doc-\u002Ferrors\u002Ftypeerror-missing-required-positional-argument-fix":3},{"id":4,"title":5,"body":6,"description":1473,"extension":1474,"meta":1475,"navigation":93,"path":1476,"seo":1477,"stem":1478,"__hash__":1479},"content\u002Ferrors\u002Ftypeerror-missing-required-positional-argument-fix.md","TypeError: missing required positional argument (Fix)",{"type":7,"value":8,"toc":1445},"minimark",[9,13,17,20,25,117,120,124,130,146,149,218,221,230,233,237,240,261,274,278,281,334,336,375,378,403,407,412,415,469,471,480,484,487,561,564,568,571,651,654,658,661,731,733,748,756,760,763,855,858,877,881,884,890,895,966,977,981,984,1066,1072,1076,1082,1145,1153,1157,1160,1185,1188,1246,1249,1337,1341,1344,1361,1368,1372,1376,1379,1383,1386,1390,1396,1400,1406,1410,1441],[10,11,5],"h1",{"id":12},"typeerror-missing-required-positional-argument-fix",[14,15,16],"p",{},"This error happens when Python expects an argument, but your code does not provide it.",[14,18,19],{},"It usually appears when you call a function or method with too few values. The message often tells you exactly which parameter is missing.",[21,22,24],"h2",{"id":23},"quick-fix","Quick fix",[26,27,32],"pre",{"className":28,"code":29,"language":30,"meta":31,"style":31},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","def greet(name):\n    print(\"Hello\", name)\n\ngreet(\"Sam\")  # pass the required argument\n","python","",[33,34,35,59,88,95],"code",{"__ignoreMap":31},[36,37,40,44,48,52,56],"span",{"class":38,"line":39},"line",1,[36,41,43],{"class":42},"sbsja","def",[36,45,47],{"class":46},"sGLFI"," greet",[36,49,51],{"class":50},"sP7_E","(",[36,53,55],{"class":54},"sFwrP","name",[36,57,58],{"class":50},"):\n",[36,60,62,66,68,72,76,78,81,85],{"class":38,"line":61},2,[36,63,65],{"class":64},"sptTA","    print",[36,67,51],{"class":50},[36,69,71],{"class":70},"sjJ54","\"",[36,73,75],{"class":74},"s_sjI","Hello",[36,77,71],{"class":70},[36,79,80],{"class":50},",",[36,82,84],{"class":83},"slqww"," name",[36,86,87],{"class":50},")\n",[36,89,91],{"class":38,"line":90},3,[36,92,94],{"emptyLinePlaceholder":93},true,"\n",[36,96,98,101,103,105,108,110,113],{"class":38,"line":97},4,[36,99,100],{"class":83},"greet",[36,102,51],{"class":50},[36,104,71],{"class":70},[36,106,107],{"class":74},"Sam",[36,109,71],{"class":70},[36,111,112],{"class":50},")",[36,114,116],{"class":115},"sutJx","  # pass the required argument\n",[14,118,119],{},"If a function expects one or more required positional arguments, you must provide them when calling it unless the function defines default values.",[21,121,123],{"id":122},"what-this-error-means","What this error means",[14,125,126,129],{},[33,127,128],{},"TypeError: missing required positional argument"," means:",[131,132,133,137,140,143],"ul",{},[134,135,136],"li",{},"Python expected an argument that was not provided",[134,138,139],{},"A positional argument is matched by its position in the function call",[134,141,142],{},"The error usually names the missing parameter",[134,144,145],{},"It can happen with your own functions, class methods, or built-in\u002Flibrary code",[14,147,148],{},"For example, if a function needs two arguments, you must pass both:",[26,150,152],{"className":28,"code":151,"language":30,"meta":31,"style":31},"def add(a, b):\n    return a + b\n\nprint(add(2, 3))\n",[33,153,154,173,190,194],{"__ignoreMap":31},[36,155,156,158,161,163,166,168,171],{"class":38,"line":39},[36,157,43],{"class":42},[36,159,160],{"class":46}," add",[36,162,51],{"class":50},[36,164,165],{"class":54},"a",[36,167,80],{"class":50},[36,169,170],{"class":54}," b",[36,172,58],{"class":50},[36,174,175,179,183,187],{"class":38,"line":61},[36,176,178],{"class":177},"sVHd0","    return",[36,180,182],{"class":181},"su5hD"," a ",[36,184,186],{"class":185},"smGrS","+",[36,188,189],{"class":181}," b\n",[36,191,192],{"class":38,"line":90},[36,193,94],{"emptyLinePlaceholder":93},[36,195,196,199,201,204,206,210,212,215],{"class":38,"line":97},[36,197,198],{"class":64},"print",[36,200,51],{"class":50},[36,202,203],{"class":83},"add",[36,205,51],{"class":50},[36,207,209],{"class":208},"srdBf","2",[36,211,80],{"class":50},[36,213,214],{"class":208}," 3",[36,216,217],{"class":50},"))\n",[14,219,220],{},"Output:",[26,222,224],{"className":28,"code":223,"language":30,"meta":31,"style":31},"5\n",[33,225,226],{"__ignoreMap":31},[36,227,228],{"class":38,"line":39},[36,229,223],{"class":208},[14,231,232],{},"If you leave one out, Python cannot complete the call.",[21,234,236],{"id":235},"why-it-happens","Why it happens",[14,238,239],{},"This error usually happens for one of these reasons:",[131,241,242,245,248,255,258],{},[134,243,244],{},"You called a function with too few arguments",[134,246,247],{},"You forgot that a method also needs values after the object name",[134,249,250,251,254],{},"You created a class method but forgot the ",[33,252,253],{},"self"," parameter in the method definition or misused it when calling",[134,256,257],{},"You changed a function definition but did not update all places that call it",[134,259,260],{},"You passed keyword arguments for some parameters but still left a required one out",[14,262,263,264,268,269,273],{},"If you are new to this topic, it helps to review ",[165,265,267],{"href":266},"\u002Flearn\u002Ffunction-parameters-and-arguments-in-python\u002F","function parameters and arguments in Python"," and ",[165,270,272],{"href":271},"\u002Flearn\u002Fdefault-and-keyword-arguments-explained\u002F","default and keyword arguments",".",[21,275,277],{"id":276},"example-that-causes-the-error","Example that causes the error",[14,279,280],{},"Here is a simple example.",[26,282,284],{"className":28,"code":283,"language":30,"meta":31,"style":31},"def multiply(a, b):\n    return a * b\n\nprint(multiply(4))\n",[33,285,286,303,314,318],{"__ignoreMap":31},[36,287,288,290,293,295,297,299,301],{"class":38,"line":39},[36,289,43],{"class":42},[36,291,292],{"class":46}," multiply",[36,294,51],{"class":50},[36,296,165],{"class":54},[36,298,80],{"class":50},[36,300,170],{"class":54},[36,302,58],{"class":50},[36,304,305,307,309,312],{"class":38,"line":61},[36,306,178],{"class":177},[36,308,182],{"class":181},[36,310,311],{"class":185},"*",[36,313,189],{"class":181},[36,315,316],{"class":38,"line":90},[36,317,94],{"emptyLinePlaceholder":93},[36,319,320,322,324,327,329,332],{"class":38,"line":97},[36,321,198],{"class":64},[36,323,51],{"class":50},[36,325,326],{"class":83},"multiply",[36,328,51],{"class":50},[36,330,331],{"class":208},"4",[36,333,217],{"class":50},[14,335,220],{},[26,337,339],{"className":28,"code":338,"language":30,"meta":31,"style":31},"TypeError: multiply() missing 1 required positional argument: 'b'\n",[33,340,341],{"__ignoreMap":31},[36,342,343,347,350,352,355,358,361,364,366,369,372],{"class":38,"line":39},[36,344,346],{"class":345},"sZMiF","TypeError",[36,348,349],{"class":50},":",[36,351,292],{"class":83},[36,353,354],{"class":50},"()",[36,356,357],{"class":181}," missing ",[36,359,360],{"class":208},"1",[36,362,363],{"class":181}," required positional argument",[36,365,349],{"class":50},[36,367,368],{"class":70}," '",[36,370,371],{"class":74},"b",[36,373,374],{"class":70},"'\n",[14,376,377],{},"What happened:",[131,379,380,387,394],{},[134,381,382,383,386],{},"The function ",[33,384,385],{},"multiply(a, b)"," requires two values",[134,388,389,390,393],{},"The call ",[33,391,392],{},"multiply(4)"," only provides one",[134,395,396,397,399,400,402],{},"Python raises ",[33,398,346],{}," because the argument for ",[33,401,371],{}," is missing",[21,404,406],{"id":405},"how-to-fix-it","How to fix it",[408,409,411],"h3",{"id":410},"pass-all-required-arguments","Pass all required arguments",[14,413,414],{},"The most direct fix is to pass every required argument.",[26,416,418],{"className":28,"code":417,"language":30,"meta":31,"style":31},"def multiply(a, b):\n    return a * b\n\nprint(multiply(4, 5))\n",[33,419,420,436,446,450],{"__ignoreMap":31},[36,421,422,424,426,428,430,432,434],{"class":38,"line":39},[36,423,43],{"class":42},[36,425,292],{"class":46},[36,427,51],{"class":50},[36,429,165],{"class":54},[36,431,80],{"class":50},[36,433,170],{"class":54},[36,435,58],{"class":50},[36,437,438,440,442,444],{"class":38,"line":61},[36,439,178],{"class":177},[36,441,182],{"class":181},[36,443,311],{"class":185},[36,445,189],{"class":181},[36,447,448],{"class":38,"line":90},[36,449,94],{"emptyLinePlaceholder":93},[36,451,452,454,456,458,460,462,464,467],{"class":38,"line":97},[36,453,198],{"class":64},[36,455,51],{"class":50},[36,457,326],{"class":83},[36,459,51],{"class":50},[36,461,331],{"class":208},[36,463,80],{"class":50},[36,465,466],{"class":208}," 5",[36,468,217],{"class":50},[14,470,220],{},[26,472,474],{"className":28,"code":473,"language":30,"meta":31,"style":31},"20\n",[33,475,476],{"__ignoreMap":31},[36,477,478],{"class":38,"line":39},[36,479,473],{"class":208},[408,481,483],{"id":482},"check-the-function-definition","Check the function definition",[14,485,486],{},"Look at the function definition and count the required parameters.",[26,488,490],{"className":28,"code":489,"language":30,"meta":31,"style":31},"def greet(first_name, last_name):\n    print(\"Hello\", first_name, last_name)\n\ngreet(\"Sam\", \"Lee\")\n",[33,491,492,510,533,537],{"__ignoreMap":31},[36,493,494,496,498,500,503,505,508],{"class":38,"line":39},[36,495,43],{"class":42},[36,497,47],{"class":46},[36,499,51],{"class":50},[36,501,502],{"class":54},"first_name",[36,504,80],{"class":50},[36,506,507],{"class":54}," last_name",[36,509,58],{"class":50},[36,511,512,514,516,518,520,522,524,527,529,531],{"class":38,"line":61},[36,513,65],{"class":64},[36,515,51],{"class":50},[36,517,71],{"class":70},[36,519,75],{"class":74},[36,521,71],{"class":70},[36,523,80],{"class":50},[36,525,526],{"class":83}," first_name",[36,528,80],{"class":50},[36,530,507],{"class":83},[36,532,87],{"class":50},[36,534,535],{"class":38,"line":90},[36,536,94],{"emptyLinePlaceholder":93},[36,538,539,541,543,545,547,549,551,554,557,559],{"class":38,"line":97},[36,540,100],{"class":83},[36,542,51],{"class":50},[36,544,71],{"class":70},[36,546,107],{"class":74},[36,548,71],{"class":70},[36,550,80],{"class":50},[36,552,553],{"class":70}," \"",[36,555,556],{"class":74},"Lee",[36,558,71],{"class":70},[36,560,87],{"class":50},[14,562,563],{},"If the function has two required parameters, the call must include two arguments.",[408,565,567],{"id":566},"use-keyword-arguments-for-clarity","Use keyword arguments for clarity",[14,569,570],{},"Keyword arguments can make the call easier to read.",[26,572,574],{"className":28,"code":573,"language":30,"meta":31,"style":31},"def greet(first_name, last_name):\n    print(\"Hello\", first_name, last_name)\n\ngreet(last_name=\"Lee\", first_name=\"Sam\")\n",[33,575,576,592,614,618],{"__ignoreMap":31},[36,577,578,580,582,584,586,588,590],{"class":38,"line":39},[36,579,43],{"class":42},[36,581,47],{"class":46},[36,583,51],{"class":50},[36,585,502],{"class":54},[36,587,80],{"class":50},[36,589,507],{"class":54},[36,591,58],{"class":50},[36,593,594,596,598,600,602,604,606,608,610,612],{"class":38,"line":61},[36,595,65],{"class":64},[36,597,51],{"class":50},[36,599,71],{"class":70},[36,601,75],{"class":74},[36,603,71],{"class":70},[36,605,80],{"class":50},[36,607,526],{"class":83},[36,609,80],{"class":50},[36,611,507],{"class":83},[36,613,87],{"class":50},[36,615,616],{"class":38,"line":90},[36,617,94],{"emptyLinePlaceholder":93},[36,619,620,622,624,628,631,633,635,637,639,641,643,645,647,649],{"class":38,"line":97},[36,621,100],{"class":83},[36,623,51],{"class":50},[36,625,627],{"class":626},"s99_P","last_name",[36,629,630],{"class":185},"=",[36,632,71],{"class":70},[36,634,556],{"class":74},[36,636,71],{"class":70},[36,638,80],{"class":50},[36,640,526],{"class":626},[36,642,630],{"class":185},[36,644,71],{"class":70},[36,646,107],{"class":74},[36,648,71],{"class":70},[36,650,87],{"class":50},[14,652,653],{},"This still passes all required values, but by name instead of position.",[408,655,657],{"id":656},"add-a-default-value-if-the-argument-should-be-optional","Add a default value if the argument should be optional",[14,659,660],{},"If a parameter should not be required, give it a default value.",[26,662,664],{"className":28,"code":663,"language":30,"meta":31,"style":31},"def greet(name=\"Guest\"):\n    print(\"Hello\", name)\n\ngreet()\ngreet(\"Sam\")\n",[33,665,666,687,705,709,716],{"__ignoreMap":31},[36,667,668,670,672,674,676,678,680,683,685],{"class":38,"line":39},[36,669,43],{"class":42},[36,671,47],{"class":46},[36,673,51],{"class":50},[36,675,55],{"class":54},[36,677,630],{"class":185},[36,679,71],{"class":70},[36,681,682],{"class":74},"Guest",[36,684,71],{"class":70},[36,686,58],{"class":50},[36,688,689,691,693,695,697,699,701,703],{"class":38,"line":61},[36,690,65],{"class":64},[36,692,51],{"class":50},[36,694,71],{"class":70},[36,696,75],{"class":74},[36,698,71],{"class":70},[36,700,80],{"class":50},[36,702,84],{"class":83},[36,704,87],{"class":50},[36,706,707],{"class":38,"line":90},[36,708,94],{"emptyLinePlaceholder":93},[36,710,711,713],{"class":38,"line":97},[36,712,100],{"class":83},[36,714,715],{"class":50},"()\n",[36,717,719,721,723,725,727,729],{"class":38,"line":718},5,[36,720,100],{"class":83},[36,722,51],{"class":50},[36,724,71],{"class":70},[36,726,107],{"class":74},[36,728,71],{"class":70},[36,730,87],{"class":50},[14,732,220],{},[26,734,736],{"className":28,"code":735,"language":30,"meta":31,"style":31},"Hello Guest\nHello Sam\n",[33,737,738,743],{"__ignoreMap":31},[36,739,740],{"class":38,"line":39},[36,741,742],{"class":181},"Hello Guest\n",[36,744,745],{"class":38,"line":61},[36,746,747],{"class":181},"Hello Sam\n",[14,749,750,751,755],{},"This is a common fix when you are designing your own functions. See ",[165,752,754],{"href":753},"\u002Fhow-to\u002Fhow-to-create-a-simple-function-in-python\u002F","how to create a simple function in Python"," for a beginner-friendly walkthrough.",[408,757,759],{"id":758},"if-the-error-comes-from-a-method-call-it-correctly","If the error comes from a method, call it correctly",[14,761,762],{},"Methods belong to objects. You usually call them on an instance.",[26,764,766],{"className":28,"code":765,"language":30,"meta":31,"style":31},"class User:\n    def show(self, name):\n        print(\"User:\", name)\n\nuser = User()\nuser.show(\"Sam\")\n",[33,767,768,780,799,819,823,834],{"__ignoreMap":31},[36,769,770,773,777],{"class":38,"line":39},[36,771,772],{"class":42},"class",[36,774,776],{"class":775},"sbgvK"," User",[36,778,779],{"class":50},":\n",[36,781,782,785,788,790,793,795,797],{"class":38,"line":61},[36,783,784],{"class":42},"    def",[36,786,787],{"class":46}," show",[36,789,51],{"class":50},[36,791,253],{"class":792},"smCYv",[36,794,80],{"class":50},[36,796,84],{"class":54},[36,798,58],{"class":50},[36,800,801,804,806,808,811,813,815,817],{"class":38,"line":90},[36,802,803],{"class":64},"        print",[36,805,51],{"class":50},[36,807,71],{"class":70},[36,809,810],{"class":74},"User:",[36,812,71],{"class":70},[36,814,80],{"class":50},[36,816,84],{"class":83},[36,818,87],{"class":50},[36,820,821],{"class":38,"line":97},[36,822,94],{"emptyLinePlaceholder":93},[36,824,825,828,830,832],{"class":38,"line":718},[36,826,827],{"class":181},"user ",[36,829,630],{"class":185},[36,831,776],{"class":83},[36,833,715],{"class":50},[36,835,837,840,842,845,847,849,851,853],{"class":38,"line":836},6,[36,838,839],{"class":181},"user",[36,841,273],{"class":50},[36,843,844],{"class":83},"show",[36,846,51],{"class":50},[36,848,71],{"class":70},[36,850,107],{"class":74},[36,852,71],{"class":70},[36,854,87],{"class":50},[14,856,857],{},"In this example:",[131,859,860,865,871],{},[134,861,862,864],{},[33,863,839],{}," is the instance",[134,866,867,868,870],{},"Python passes ",[33,869,253],{}," automatically",[134,872,873,874],{},"You only need to pass the remaining required argument: ",[33,875,876],{},"\"Sam\"",[21,878,880],{"id":879},"special-case-methods-and-self","Special case: methods and self",[14,882,883],{},"This error is common when working with classes.",[408,885,887,888,870],{"id":886},"instance-methods-receive-self-automatically","Instance methods receive ",[33,889,253],{},[14,891,892,893,273],{},"When you define an instance method, the first parameter is usually ",[33,894,253],{},[26,896,898],{"className":28,"code":897,"language":30,"meta":31,"style":31},"class User:\n    def show(self, name):\n        print(name)\n\nuser = User()\nuser.show(\"Sam\")\n",[33,899,900,908,924,934,938,948],{"__ignoreMap":31},[36,901,902,904,906],{"class":38,"line":39},[36,903,772],{"class":42},[36,905,776],{"class":775},[36,907,779],{"class":50},[36,909,910,912,914,916,918,920,922],{"class":38,"line":61},[36,911,784],{"class":42},[36,913,787],{"class":46},[36,915,51],{"class":50},[36,917,253],{"class":792},[36,919,80],{"class":50},[36,921,84],{"class":54},[36,923,58],{"class":50},[36,925,926,928,930,932],{"class":38,"line":90},[36,927,803],{"class":64},[36,929,51],{"class":50},[36,931,55],{"class":83},[36,933,87],{"class":50},[36,935,936],{"class":38,"line":97},[36,937,94],{"emptyLinePlaceholder":93},[36,939,940,942,944,946],{"class":38,"line":718},[36,941,827],{"class":181},[36,943,630],{"class":185},[36,945,776],{"class":83},[36,947,715],{"class":50},[36,949,950,952,954,956,958,960,962,964],{"class":38,"line":836},[36,951,839],{"class":181},[36,953,273],{"class":50},[36,955,844],{"class":83},[36,957,51],{"class":50},[36,959,71],{"class":70},[36,961,107],{"class":74},[36,963,71],{"class":70},[36,965,87],{"class":50},[14,967,968,969,973,974,976],{},"You do ",[970,971,972],"strong",{},"not"," pass ",[33,975,253],{}," yourself in a normal method call.",[408,978,980],{"id":979},"do-not-call-the-method-incorrectly-on-the-class","Do not call the method incorrectly on the class",[14,982,983],{},"This can cause an argument mismatch.",[26,985,987],{"className":28,"code":986,"language":30,"meta":31,"style":31},"class User:\n    def show(self, name):\n        print(name)\n\nuser = User()\n\n# Correct\nuser.show(\"Sam\")\n",[33,988,989,997,1013,1023,1027,1037,1041,1047],{"__ignoreMap":31},[36,990,991,993,995],{"class":38,"line":39},[36,992,772],{"class":42},[36,994,776],{"class":775},[36,996,779],{"class":50},[36,998,999,1001,1003,1005,1007,1009,1011],{"class":38,"line":61},[36,1000,784],{"class":42},[36,1002,787],{"class":46},[36,1004,51],{"class":50},[36,1006,253],{"class":792},[36,1008,80],{"class":50},[36,1010,84],{"class":54},[36,1012,58],{"class":50},[36,1014,1015,1017,1019,1021],{"class":38,"line":90},[36,1016,803],{"class":64},[36,1018,51],{"class":50},[36,1020,55],{"class":83},[36,1022,87],{"class":50},[36,1024,1025],{"class":38,"line":97},[36,1026,94],{"emptyLinePlaceholder":93},[36,1028,1029,1031,1033,1035],{"class":38,"line":718},[36,1030,827],{"class":181},[36,1032,630],{"class":185},[36,1034,776],{"class":83},[36,1036,715],{"class":50},[36,1038,1039],{"class":38,"line":836},[36,1040,94],{"emptyLinePlaceholder":93},[36,1042,1044],{"class":38,"line":1043},7,[36,1045,1046],{"class":115},"# Correct\n",[36,1048,1050,1052,1054,1056,1058,1060,1062,1064],{"class":38,"line":1049},8,[36,1051,839],{"class":181},[36,1053,273],{"class":50},[36,1055,844],{"class":83},[36,1057,51],{"class":50},[36,1059,71],{"class":70},[36,1061,107],{"class":74},[36,1063,71],{"class":70},[36,1065,87],{"class":50},[14,1067,1068,1069,1071],{},"If you call the method on the class instead of the instance, you may get confusing errors because Python is no longer filling ",[33,1070,253],{}," for you in the usual way.",[408,1073,1075],{"id":1074},"make-sure-the-method-definition-is-correct","Make sure the method definition is correct",[14,1077,1078,1079,1081],{},"If you forget ",[33,1080,253],{}," in the method definition, the parameters will not line up correctly.",[26,1083,1085],{"className":28,"code":1084,"language":30,"meta":31,"style":31},"class User:\n    def show(name):  # incorrect\n        print(name)\n\nuser = User()\nuser.show()\n",[33,1086,1087,1095,1111,1121,1125,1135],{"__ignoreMap":31},[36,1088,1089,1091,1093],{"class":38,"line":39},[36,1090,772],{"class":42},[36,1092,776],{"class":775},[36,1094,779],{"class":50},[36,1096,1097,1099,1101,1103,1105,1108],{"class":38,"line":61},[36,1098,784],{"class":42},[36,1100,787],{"class":46},[36,1102,51],{"class":50},[36,1104,55],{"class":54},[36,1106,1107],{"class":50},"):",[36,1109,1110],{"class":115},"  # incorrect\n",[36,1112,1113,1115,1117,1119],{"class":38,"line":90},[36,1114,803],{"class":64},[36,1116,51],{"class":50},[36,1118,55],{"class":83},[36,1120,87],{"class":50},[36,1122,1123],{"class":38,"line":97},[36,1124,94],{"emptyLinePlaceholder":93},[36,1126,1127,1129,1131,1133],{"class":38,"line":718},[36,1128,827],{"class":181},[36,1130,630],{"class":185},[36,1132,776],{"class":83},[36,1134,715],{"class":50},[36,1136,1137,1139,1141,1143],{"class":38,"line":836},[36,1138,839],{"class":181},[36,1140,273],{"class":50},[36,1142,844],{"class":83},[36,1144,715],{"class":50},[14,1146,1147,1148,1152],{},"This method definition is wrong for a normal instance method. If you are learning functions first, start with ",[165,1149,1151],{"href":1150},"\u002Flearn\u002Fpython-functions-explained\u002F","Python functions explained"," before moving deeper into classes.",[21,1154,1156],{"id":1155},"how-to-debug-it-step-by-step","How to debug it step by step",[14,1158,1159],{},"When you see this error, use this checklist:",[1161,1162,1163,1166,1169,1172,1175,1178],"ol",{},[134,1164,1165],{},"Read the full error message and note the missing parameter name",[134,1167,1168],{},"Find the exact line where the function or method is called",[134,1170,1171],{},"Compare the call with the function definition",[134,1173,1174],{},"Count how many required parameters exist",[134,1176,1177],{},"Check whether some parameters already have default values and which do not",[134,1179,1180,1181,1184],{},"If using an editor, hover over the function name or use ",[33,1182,1183],{},"help()"," to inspect the signature",[14,1186,1187],{},"Useful debugging commands:",[26,1189,1191],{"className":28,"code":1190,"language":30,"meta":31,"style":31},"help(function_name)\nprint(function_name)\nprint(type(object_name))\nprint(vars(object_name))\n",[33,1192,1193,1205,1215,1231],{"__ignoreMap":31},[36,1194,1195,1198,1200,1203],{"class":38,"line":39},[36,1196,1197],{"class":64},"help",[36,1199,51],{"class":50},[36,1201,1202],{"class":83},"function_name",[36,1204,87],{"class":50},[36,1206,1207,1209,1211,1213],{"class":38,"line":61},[36,1208,198],{"class":64},[36,1210,51],{"class":50},[36,1212,1202],{"class":83},[36,1214,87],{"class":50},[36,1216,1217,1219,1221,1224,1226,1229],{"class":38,"line":90},[36,1218,198],{"class":64},[36,1220,51],{"class":50},[36,1222,1223],{"class":345},"type",[36,1225,51],{"class":50},[36,1227,1228],{"class":83},"object_name",[36,1230,217],{"class":50},[36,1232,1233,1235,1237,1240,1242,1244],{"class":38,"line":97},[36,1234,198],{"class":64},[36,1236,51],{"class":50},[36,1238,1239],{"class":64},"vars",[36,1241,51],{"class":50},[36,1243,1228],{"class":83},[36,1245,217],{"class":50},[14,1247,1248],{},"If you want to print the full traceback inside a larger program:",[26,1250,1252],{"className":28,"code":1251,"language":30,"meta":31,"style":31},"import traceback\n\ntry:\n    def greet(name):\n        print(\"Hello\", name)\n\n    greet()\nexcept Exception:\n    traceback.print_exc()\n",[33,1253,1254,1262,1266,1273,1285,1303,1307,1314,1324],{"__ignoreMap":31},[36,1255,1256,1259],{"class":38,"line":39},[36,1257,1258],{"class":177},"import",[36,1260,1261],{"class":181}," traceback\n",[36,1263,1264],{"class":38,"line":61},[36,1265,94],{"emptyLinePlaceholder":93},[36,1267,1268,1271],{"class":38,"line":90},[36,1269,1270],{"class":177},"try",[36,1272,779],{"class":50},[36,1274,1275,1277,1279,1281,1283],{"class":38,"line":97},[36,1276,784],{"class":42},[36,1278,47],{"class":46},[36,1280,51],{"class":50},[36,1282,55],{"class":54},[36,1284,58],{"class":50},[36,1286,1287,1289,1291,1293,1295,1297,1299,1301],{"class":38,"line":718},[36,1288,803],{"class":64},[36,1290,51],{"class":50},[36,1292,71],{"class":70},[36,1294,75],{"class":74},[36,1296,71],{"class":70},[36,1298,80],{"class":50},[36,1300,84],{"class":83},[36,1302,87],{"class":50},[36,1304,1305],{"class":38,"line":836},[36,1306,94],{"emptyLinePlaceholder":93},[36,1308,1309,1312],{"class":38,"line":1043},[36,1310,1311],{"class":83},"    greet",[36,1313,715],{"class":50},[36,1315,1316,1319,1322],{"class":38,"line":1049},[36,1317,1318],{"class":177},"except",[36,1320,1321],{"class":345}," Exception",[36,1323,779],{"class":50},[36,1325,1327,1330,1332,1335],{"class":38,"line":1326},9,[36,1328,1329],{"class":181},"    traceback",[36,1331,273],{"class":50},[36,1333,1334],{"class":83},"print_exc",[36,1336,715],{"class":50},[21,1338,1340],{"id":1339},"common-mistakes","Common mistakes",[14,1342,1343],{},"These are the most common causes of this error:",[131,1345,1346,1349,1352,1355,1358],{},[134,1347,1348],{},"Calling a function with too few arguments",[134,1350,1351],{},"Forgetting one argument after editing a function definition",[134,1353,1354],{},"Calling an instance method incorrectly",[134,1356,1357],{},"Assuming a parameter is optional when it is not",[134,1359,1360],{},"Mixing positional and keyword arguments and leaving one out",[14,1362,1363,1364,273],{},"A related problem is passing the wrong parameter name. If that happens, see ",[165,1365,1367],{"href":1366},"\u002Ferrors\u002Ftypeerror-unexpected-keyword-argument-fix\u002F","TypeError: unexpected keyword argument",[21,1369,1371],{"id":1370},"faq","FAQ",[408,1373,1375],{"id":1374},"what-is-a-positional-argument-in-python","What is a positional argument in Python?",[14,1377,1378],{},"It is an argument matched to a parameter by its position in the function call, such as the first or second value passed.",[408,1380,1382],{"id":1381},"can-i-fix-this-by-using-keyword-arguments","Can I fix this by using keyword arguments?",[14,1384,1385],{},"Yes. If you provide the missing required parameter by name, the call can be clearer and easier to read.",[408,1387,1389],{"id":1388},"why-does-this-happen-with-class-methods","Why does this happen with class methods?",[14,1391,1392,1393,1395],{},"Methods have specific parameters too. For instance methods, Python passes ",[33,1394,253],{}," automatically when you call the method on an object.",[408,1397,1399],{"id":1398},"how-do-i-make-an-argument-optional","How do I make an argument optional?",[14,1401,1402,1403,273],{},"Give the parameter a default value in the function definition, such as ",[33,1404,1405],{},"name=\"Guest\"",[21,1407,1409],{"id":1408},"see-also","See also",[131,1411,1412,1417,1422,1426,1431,1435],{},[134,1413,1414],{},[165,1415,1416],{"href":266},"Function parameters and arguments in Python",[134,1418,1419],{},[165,1420,1421],{"href":271},"Default and keyword arguments explained",[134,1423,1424],{},[165,1425,1151],{"href":1150},[134,1427,1428],{},[165,1429,1430],{"href":753},"How to create a simple function in Python",[134,1432,1433],{},[165,1434,1367],{"href":1366},[134,1436,1437],{},[165,1438,1440],{"href":1439},"\u002Ferrors\u002Ftypeerror-list-object-is-not-callable-fix\u002F","TypeError: 'list' object is not callable",[1442,1443,1444],"style",{},"html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sFwrP, html code.shiki .sFwrP{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#24292E;--shiki-default-font-style:inherit;--shiki-dark:#E1E4E8;--shiki-dark-font-style:inherit}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sutJx, html code.shiki .sutJx{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html .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 .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 .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--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 .s99_P, html code.shiki .s99_P{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#E36209;--shiki-default-font-style:inherit;--shiki-dark:#FFAB70;--shiki-dark-font-style:inherit}html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .smCYv, html code.shiki .smCYv{--shiki-light:#E53935;--shiki-light-font-style:italic;--shiki-default:#24292E;--shiki-default-font-style:inherit;--shiki-dark:#E1E4E8;--shiki-dark-font-style:inherit}",{"title":31,"searchDepth":61,"depth":61,"links":1446},[1447,1448,1449,1450,1451,1458,1464,1465,1466,1472],{"id":23,"depth":61,"text":24},{"id":122,"depth":61,"text":123},{"id":235,"depth":61,"text":236},{"id":276,"depth":61,"text":277},{"id":405,"depth":61,"text":406,"children":1452},[1453,1454,1455,1456,1457],{"id":410,"depth":90,"text":411},{"id":482,"depth":90,"text":483},{"id":566,"depth":90,"text":567},{"id":656,"depth":90,"text":657},{"id":758,"depth":90,"text":759},{"id":879,"depth":61,"text":880,"children":1459},[1460,1462,1463],{"id":886,"depth":90,"text":1461},"Instance methods receive self automatically",{"id":979,"depth":90,"text":980},{"id":1074,"depth":90,"text":1075},{"id":1155,"depth":61,"text":1156},{"id":1339,"depth":61,"text":1340},{"id":1370,"depth":61,"text":1371,"children":1467},[1468,1469,1470,1471],{"id":1374,"depth":90,"text":1375},{"id":1381,"depth":90,"text":1382},{"id":1388,"depth":90,"text":1389},{"id":1398,"depth":90,"text":1399},{"id":1408,"depth":61,"text":1409},"Master typeerror missing required positional argument fix in our comprehensive Python beginner guide.","md",{},"\u002Ferrors\u002Ftypeerror-missing-required-positional-argument-fix",{"title":5,"description":1473},"errors\u002Ftypeerror-missing-required-positional-argument-fix","EdIX3FcLrS886ey_5k51JRVvq3KDfiyP97T2h8_202w",1777585497647]