[{"data":1,"prerenderedAt":1907},["ShallowReactive",2],{"doc-\u002Ferrors\u002Fattributeerror-object-has-no-attribute-fix":3},{"id":4,"title":5,"body":6,"description":1900,"extension":1901,"meta":1902,"navigation":123,"path":1903,"seo":1904,"stem":1905,"__hash__":1906},"content\u002Ferrors\u002Fattributeerror-object-has-no-attribute-fix.md","AttributeError: object has no attribute (Fix)",{"type":7,"value":8,"toc":1866},"minimark",[9,13,17,20,30,42,53,58,203,210,214,220,223,234,237,265,268,303,306,316,322,378,380,414,418,421,442,445,477,484,488,493,548,554,563,592,600,606,685,687,720,728,732,764,773,776,780,783,787,795,847,849,872,875,879,882,919,922,929,938,970,973,977,982,985,1042,1045,1104,1106,1133,1137,1140,1187,1190,1272,1274,1310,1314,1316,1348,1350,1380,1382,1390,1394,1400,1405,1408,1428,1435,1441,1444,1447,1499,1503,1510,1516,1519,1521,1557,1562,1568,1572,1575,1577,1611,1617,1619,1650,1652,1661,1665,1668,1692,1695,1753,1760,1764,1768,1778,1782,1796,1800,1806,1810,1820,1824,1862],[10,11,5],"h1",{"id":12},"attributeerror-object-has-no-attribute-fix",[14,15,16],"p",{},"This error happens when Python finds the object before the dot, but cannot find the attribute or method after the dot.",[14,18,19],{},"In simple terms:",[21,22,23,27],"ul",{},[24,25,26],"li",{},"The variable exists",[24,28,29],{},"But that kind of object does not have the thing you tried to use",[14,31,32,33,37,38,41],{},"For example, a list has ",[34,35,36],"code",{},"append()",", but an integer does not. A string has ",[34,39,40],{},"upper()",", but a list does not.",[14,43,44,45,52],{},"If you are not sure what value you actually have, start by checking its type with ",[46,47,49],"a",{"href":48},"\u002Freference\u002Fpython-type-function-explained\u002F",[34,50,51],{},"type()",".",[54,55,57],"h2",{"id":56},"quick-fix","Quick fix",[59,60,65],"pre",{"className":61,"code":62,"language":63,"meta":64,"style":64},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","name = \"Python\"\nprint(name.upper())   # correct: strings have upper()\n\nnumbers = [1, 2, 3]\nprint(numbers.append(4))  # correct: lists have append()\n\nvalue = None\n# print(value.append(1))  # wrong: None has no append()\n","python","",[34,66,67,91,118,125,154,180,185,197],{"__ignoreMap":64},[68,69,72,76,80,84,88],"span",{"class":70,"line":71},"line",1,[68,73,75],{"class":74},"su5hD","name ",[68,77,79],{"class":78},"smGrS","=",[68,81,83],{"class":82},"sjJ54"," \"",[68,85,87],{"class":86},"s_sjI","Python",[68,89,90],{"class":82},"\"\n",[68,92,94,98,102,106,108,111,114],{"class":70,"line":93},2,[68,95,97],{"class":96},"sptTA","print",[68,99,101],{"class":100},"sP7_E","(",[68,103,105],{"class":104},"slqww","name",[68,107,52],{"class":100},[68,109,110],{"class":104},"upper",[68,112,113],{"class":100},"())",[68,115,117],{"class":116},"sutJx","   # correct: strings have upper()\n",[68,119,121],{"class":70,"line":120},3,[68,122,124],{"emptyLinePlaceholder":123},true,"\n",[68,126,128,131,133,136,140,143,146,148,151],{"class":70,"line":127},4,[68,129,130],{"class":74},"numbers ",[68,132,79],{"class":78},[68,134,135],{"class":100}," [",[68,137,139],{"class":138},"srdBf","1",[68,141,142],{"class":100},",",[68,144,145],{"class":138}," 2",[68,147,142],{"class":100},[68,149,150],{"class":138}," 3",[68,152,153],{"class":100},"]\n",[68,155,157,159,161,164,166,169,171,174,177],{"class":70,"line":156},5,[68,158,97],{"class":96},[68,160,101],{"class":100},[68,162,163],{"class":104},"numbers",[68,165,52],{"class":100},[68,167,168],{"class":104},"append",[68,170,101],{"class":100},[68,172,173],{"class":138},"4",[68,175,176],{"class":100},"))",[68,178,179],{"class":116},"  # correct: lists have append()\n",[68,181,183],{"class":70,"line":182},6,[68,184,124],{"emptyLinePlaceholder":123},[68,186,188,191,193],{"class":70,"line":187},7,[68,189,190],{"class":74},"value ",[68,192,79],{"class":78},[68,194,196],{"class":195},"s39Yj"," None\n",[68,198,200],{"class":70,"line":199},8,[68,201,202],{"class":116},"# print(value.append(1))  # wrong: None has no append()\n",[14,204,205,206,209],{},"Check the real type of the value with ",[34,207,208],{},"print(type(value))"," and confirm that the attribute or method exists for that type.",[54,211,213],{"id":212},"what-this-error-means","What this error means",[14,215,216,219],{},[34,217,218],{},"AttributeError"," means Python could not find the attribute or method after the dot.",[14,221,222],{},"An attribute is something attached to an object, such as:",[21,224,225,228,231],{},[24,226,227],{},"A value",[24,229,230],{},"A method",[24,232,233],{},"A property",[14,235,236],{},"Examples:",[21,238,239,248,256],{},[24,240,241,242,244,245],{},"Strings have methods like ",[34,243,40],{}," and ",[34,246,247],{},"split()",[24,249,250,251,244,253],{},"Lists have methods like ",[34,252,36],{},[34,254,255],{},"sort()",[24,257,258,259,244,262],{},"Dictionaries have methods like ",[34,260,261],{},"keys()",[34,263,264],{},"get()",[14,266,267],{},"This works:",[59,269,271],{"className":61,"code":270,"language":63,"meta":64,"style":64},"text = \"hello\"\nprint(text.upper())\n",[34,272,273,287],{"__ignoreMap":64},[68,274,275,278,280,282,285],{"class":70,"line":71},[68,276,277],{"class":74},"text ",[68,279,79],{"class":78},[68,281,83],{"class":82},[68,283,284],{"class":86},"hello",[68,286,90],{"class":82},[68,288,289,291,293,296,298,300],{"class":70,"line":93},[68,290,97],{"class":96},[68,292,101],{"class":100},[68,294,295],{"class":104},"text",[68,297,52],{"class":100},[68,299,110],{"class":104},[68,301,302],{"class":100},"())\n",[14,304,305],{},"Output:",[59,307,309],{"className":61,"code":308,"language":63,"meta":64,"style":64},"HELLO\n",[34,310,311],{"__ignoreMap":64},[68,312,313],{"class":70,"line":71},[68,314,308],{"class":315},"s_hVV",[14,317,318,319,321],{},"But this fails because a list does not have ",[34,320,40],{},":",[59,323,325],{"className":61,"code":324,"language":63,"meta":64,"style":64},"items = [\"a\", \"b\", \"c\"]\nprint(items.upper())\n",[34,326,327,363],{"__ignoreMap":64},[68,328,329,332,334,336,339,341,343,345,347,350,352,354,356,359,361],{"class":70,"line":71},[68,330,331],{"class":74},"items ",[68,333,79],{"class":78},[68,335,135],{"class":100},[68,337,338],{"class":82},"\"",[68,340,46],{"class":86},[68,342,338],{"class":82},[68,344,142],{"class":100},[68,346,83],{"class":82},[68,348,349],{"class":86},"b",[68,351,338],{"class":82},[68,353,142],{"class":100},[68,355,83],{"class":82},[68,357,358],{"class":86},"c",[68,360,338],{"class":82},[68,362,153],{"class":100},[68,364,365,367,369,372,374,376],{"class":70,"line":93},[68,366,97],{"class":96},[68,368,101],{"class":100},[68,370,371],{"class":104},"items",[68,373,52],{"class":100},[68,375,110],{"class":104},[68,377,302],{"class":100},[14,379,305],{},[59,381,383],{"className":61,"code":382,"language":63,"meta":64,"style":64},"AttributeError: 'list' object has no attribute 'upper'\n",[34,384,385],{"__ignoreMap":64},[68,386,387,390,392,395,398,401,404,407,409,411],{"class":70,"line":71},[68,388,218],{"class":389},"sZMiF",[68,391,321],{"class":100},[68,393,394],{"class":82}," '",[68,396,397],{"class":86},"list",[68,399,400],{"class":82},"'",[68,402,403],{"class":389}," object",[68,405,406],{"class":74}," has no attribute ",[68,408,400],{"class":82},[68,410,110],{"class":86},[68,412,413],{"class":82},"'\n",[54,415,417],{"id":416},"why-this-happens","Why this happens",[14,419,420],{},"This error usually appears for one of these reasons:",[21,422,423,426,429,436,439],{},[24,424,425],{},"You used a method that belongs to a different type",[24,427,428],{},"A variable contains a different value than you expected",[24,430,431,432,435],{},"A function returned ",[34,433,434],{},"None",", but you treated it like a list, string, or dictionary",[24,437,438],{},"There is a spelling mistake in the attribute name",[24,440,441],{},"You expected a module, class, or object to provide something that it does not",[14,443,444],{},"Common examples:",[21,446,447,450,453,466,471,474],{},[24,448,449],{},"Calling a list method on a string or tuple",[24,451,452],{},"Calling a string method on a list",[24,454,455,456,459,460,462,463,465],{},"Using the result of ",[34,457,458],{},"print()",", ",[34,461,255],{},", or ",[34,464,36],{}," as if it were a new object",[24,467,468,469],{},"Trying to use methods on ",[34,470,434],{},[24,472,473],{},"Misspelling a method name",[24,475,476],{},"Confusing module names, class names, and instance methods",[14,478,479,480,52],{},"If you want a broader introduction to Python exceptions, see ",[46,481,483],{"href":482},"\u002Flearn\u002Fpython-errors-and-exceptions-explained\u002F","Python errors and exceptions explained",[54,485,487],{"id":486},"example-that-causes-the-error","Example that causes the error",[489,490,492],"h3",{"id":491},"using-a-string-method-on-a-list","Using a string method on a list",[59,494,496],{"className":61,"code":495,"language":63,"meta":64,"style":64},"words = [\"python\", \"is\", \"fun\"]\nprint(words.upper())\n",[34,497,498,533],{"__ignoreMap":64},[68,499,500,503,505,507,509,511,513,515,517,520,522,524,526,529,531],{"class":70,"line":71},[68,501,502],{"class":74},"words ",[68,504,79],{"class":78},[68,506,135],{"class":100},[68,508,338],{"class":82},[68,510,63],{"class":86},[68,512,338],{"class":82},[68,514,142],{"class":100},[68,516,83],{"class":82},[68,518,519],{"class":86},"is",[68,521,338],{"class":82},[68,523,142],{"class":100},[68,525,83],{"class":82},[68,527,528],{"class":86},"fun",[68,530,338],{"class":82},[68,532,153],{"class":100},[68,534,535,537,539,542,544,546],{"class":70,"line":93},[68,536,97],{"class":96},[68,538,101],{"class":100},[68,540,541],{"class":104},"words",[68,543,52],{"class":100},[68,545,110],{"class":104},[68,547,302],{"class":100},[14,549,550,551,553],{},"This fails because ",[34,552,40],{}," is a string method, not a list method.",[489,555,557,558,560,561],{"id":556},"calling-append-on-none","Calling ",[34,559,36],{}," on ",[34,562,434],{},[59,564,566],{"className":61,"code":565,"language":63,"meta":64,"style":64},"value = None\nvalue.append(1)\n",[34,567,568,576],{"__ignoreMap":64},[68,569,570,572,574],{"class":70,"line":71},[68,571,190],{"class":74},[68,573,79],{"class":78},[68,575,196],{"class":195},[68,577,578,581,583,585,587,589],{"class":70,"line":93},[68,579,580],{"class":74},"value",[68,582,52],{"class":100},[68,584,168],{"class":104},[68,586,101],{"class":100},[68,588,139],{"class":138},[68,590,591],{"class":100},")\n",[14,593,550,594,596,597,599],{},[34,595,434],{}," does not have an ",[34,598,36],{}," method.",[14,601,602,603,605],{},"A common reason is that a function returned ",[34,604,434],{}," and you used it as if it were a list:",[59,607,609],{"className":61,"code":608,"language":63,"meta":64,"style":64},"numbers = [3, 1, 2]\nresult = numbers.sort()\n\nprint(result)\nprint(result.append(4))\n",[34,610,611,633,651,655,666],{"__ignoreMap":64},[68,612,613,615,617,619,622,624,627,629,631],{"class":70,"line":71},[68,614,130],{"class":74},[68,616,79],{"class":78},[68,618,135],{"class":100},[68,620,621],{"class":138},"3",[68,623,142],{"class":100},[68,625,626],{"class":138}," 1",[68,628,142],{"class":100},[68,630,145],{"class":138},[68,632,153],{"class":100},[68,634,635,638,640,643,645,648],{"class":70,"line":93},[68,636,637],{"class":74},"result ",[68,639,79],{"class":78},[68,641,642],{"class":74}," numbers",[68,644,52],{"class":100},[68,646,647],{"class":104},"sort",[68,649,650],{"class":100},"()\n",[68,652,653],{"class":70,"line":120},[68,654,124],{"emptyLinePlaceholder":123},[68,656,657,659,661,664],{"class":70,"line":127},[68,658,97],{"class":96},[68,660,101],{"class":100},[68,662,663],{"class":104},"result",[68,665,591],{"class":100},[68,667,668,670,672,674,676,678,680,682],{"class":70,"line":156},[68,669,97],{"class":96},[68,671,101],{"class":100},[68,673,663],{"class":104},[68,675,52],{"class":100},[68,677,168],{"class":104},[68,679,101],{"class":100},[68,681,173],{"class":138},[68,683,684],{"class":100},"))\n",[14,686,305],{},[59,688,690],{"className":61,"code":689,"language":63,"meta":64,"style":64},"None\nAttributeError: 'NoneType' object has no attribute 'append'\n",[34,691,692,697],{"__ignoreMap":64},[68,693,694],{"class":70,"line":71},[68,695,696],{"class":195},"None\n",[68,698,699,701,703,705,708,710,712,714,716,718],{"class":70,"line":93},[68,700,218],{"class":389},[68,702,321],{"class":100},[68,704,394],{"class":82},[68,706,707],{"class":86},"NoneType",[68,709,400],{"class":82},[68,711,403],{"class":389},[68,713,406],{"class":74},[68,715,400],{"class":82},[68,717,168],{"class":86},[68,719,413],{"class":82},[14,721,722,725,726,52],{},[34,723,724],{},"list.sort()"," changes the list in place and returns ",[34,727,434],{},[489,729,731],{"id":730},"misspelling-an-attribute-name","Misspelling an attribute name",[59,733,735],{"className":61,"code":734,"language":63,"meta":64,"style":64},"name = \"Python\"\nprint(name.uper())\n",[34,736,737,749],{"__ignoreMap":64},[68,738,739,741,743,745,747],{"class":70,"line":71},[68,740,75],{"class":74},[68,742,79],{"class":78},[68,744,83],{"class":82},[68,746,87],{"class":86},[68,748,90],{"class":82},[68,750,751,753,755,757,759,762],{"class":70,"line":93},[68,752,97],{"class":96},[68,754,101],{"class":100},[68,756,105],{"class":104},[68,758,52],{"class":100},[68,760,761],{"class":104},"uper",[68,763,302],{"class":100},[14,765,766,767,769,770,52],{},"This fails because the method name is ",[34,768,40],{},", not ",[34,771,772],{},"uper()",[14,774,775],{},"Python method names are case-sensitive, so spelling and capitalization both matter.",[54,777,779],{"id":778},"how-to-fix-it","How to fix it",[14,781,782],{},"Here are the most useful ways to fix this error.",[489,784,786],{"id":785},"_1-check-the-object-type","1. Check the object type",[14,788,789,790,794],{},"Use ",[46,791,792],{"href":48},[34,793,51],{}," to see what the value really is:",[59,796,798],{"className":61,"code":797,"language":63,"meta":64,"style":64},"value = [\"a\", \"b\", \"c\"]\nprint(type(value))\n",[34,799,800,832],{"__ignoreMap":64},[68,801,802,804,806,808,810,812,814,816,818,820,822,824,826,828,830],{"class":70,"line":71},[68,803,190],{"class":74},[68,805,79],{"class":78},[68,807,135],{"class":100},[68,809,338],{"class":82},[68,811,46],{"class":86},[68,813,338],{"class":82},[68,815,142],{"class":100},[68,817,83],{"class":82},[68,819,349],{"class":86},[68,821,338],{"class":82},[68,823,142],{"class":100},[68,825,83],{"class":82},[68,827,358],{"class":86},[68,829,338],{"class":82},[68,831,153],{"class":100},[68,833,834,836,838,841,843,845],{"class":70,"line":93},[68,835,97],{"class":96},[68,837,101],{"class":100},[68,839,840],{"class":389},"type",[68,842,101],{"class":100},[68,844,580],{"class":104},[68,846,684],{"class":100},[14,848,305],{},[59,850,852],{"className":61,"code":851,"language":63,"meta":64,"style":64},"\u003Cclass 'list'>\n",[34,853,854],{"__ignoreMap":64},[68,855,856,859,863,865,867,869],{"class":70,"line":71},[68,857,858],{"class":78},"\u003C",[68,860,862],{"class":861},"sbsja","class",[68,864,394],{"class":82},[68,866,397],{"class":86},[68,868,400],{"class":82},[68,870,871],{"class":78},">\n",[14,873,874],{},"If the type is not what you expected, trace back to where that value came from.",[489,876,878],{"id":877},"_2-print-the-value-before-the-failing-line","2. Print the value before the failing line",[14,880,881],{},"Sometimes the variable changed earlier in the program.",[59,883,885],{"className":61,"code":884,"language":63,"meta":64,"style":64},"result = None\nprint(result)\nprint(type(result))\n",[34,886,887,895,905],{"__ignoreMap":64},[68,888,889,891,893],{"class":70,"line":71},[68,890,637],{"class":74},[68,892,79],{"class":78},[68,894,196],{"class":195},[68,896,897,899,901,903],{"class":70,"line":93},[68,898,97],{"class":96},[68,900,101],{"class":100},[68,902,663],{"class":104},[68,904,591],{"class":100},[68,906,907,909,911,913,915,917],{"class":70,"line":120},[68,908,97],{"class":96},[68,910,101],{"class":100},[68,912,840],{"class":389},[68,914,101],{"class":100},[68,916,663],{"class":104},[68,918,684],{"class":100},[14,920,921],{},"This helps you confirm what Python is actually working with.",[489,923,925,926],{"id":924},"_3-inspect-available-attributes-with-dir","3. Inspect available attributes with ",[34,927,928],{},"dir()",[14,930,931,932,937],{},"You can use ",[46,933,935],{"href":934},"\u002Freference\u002Fpython-dir-function-explained\u002F",[34,936,928],{}," to list what an object supports:",[59,939,941],{"className":61,"code":940,"language":63,"meta":64,"style":64},"text = \"hello\"\nprint(dir(text))\n",[34,942,943,955],{"__ignoreMap":64},[68,944,945,947,949,951,953],{"class":70,"line":71},[68,946,277],{"class":74},[68,948,79],{"class":78},[68,950,83],{"class":82},[68,952,284],{"class":86},[68,954,90],{"class":82},[68,956,957,959,961,964,966,968],{"class":70,"line":93},[68,958,97],{"class":96},[68,960,101],{"class":100},[68,962,963],{"class":96},"dir",[68,965,101],{"class":100},[68,967,295],{"class":104},[68,969,684],{"class":100},[14,971,972],{},"This can help you check whether a method really exists.",[489,974,976],{"id":975},"_4-check-function-return-values-before-chaining-methods","4. Check function return values before chaining methods",[14,978,979,980,52],{},"Some methods return a new object. Others change the original object and return ",[34,981,434],{},[14,983,984],{},"Bad example:",[59,986,988],{"className":61,"code":987,"language":63,"meta":64,"style":64},"numbers = [3, 1, 2]\nresult = numbers.sort()\nprint(result.append(4))\n",[34,989,990,1010,1024],{"__ignoreMap":64},[68,991,992,994,996,998,1000,1002,1004,1006,1008],{"class":70,"line":71},[68,993,130],{"class":74},[68,995,79],{"class":78},[68,997,135],{"class":100},[68,999,621],{"class":138},[68,1001,142],{"class":100},[68,1003,626],{"class":138},[68,1005,142],{"class":100},[68,1007,145],{"class":138},[68,1009,153],{"class":100},[68,1011,1012,1014,1016,1018,1020,1022],{"class":70,"line":93},[68,1013,637],{"class":74},[68,1015,79],{"class":78},[68,1017,642],{"class":74},[68,1019,52],{"class":100},[68,1021,647],{"class":104},[68,1023,650],{"class":100},[68,1025,1026,1028,1030,1032,1034,1036,1038,1040],{"class":70,"line":120},[68,1027,97],{"class":96},[68,1029,101],{"class":100},[68,1031,663],{"class":104},[68,1033,52],{"class":100},[68,1035,168],{"class":104},[68,1037,101],{"class":100},[68,1039,173],{"class":138},[68,1041,684],{"class":100},[14,1043,1044],{},"Correct version:",[59,1046,1048],{"className":61,"code":1047,"language":63,"meta":64,"style":64},"numbers = [3, 1, 2]\nnumbers.sort()\nnumbers.append(4)\nprint(numbers)\n",[34,1049,1050,1070,1080,1094],{"__ignoreMap":64},[68,1051,1052,1054,1056,1058,1060,1062,1064,1066,1068],{"class":70,"line":71},[68,1053,130],{"class":74},[68,1055,79],{"class":78},[68,1057,135],{"class":100},[68,1059,621],{"class":138},[68,1061,142],{"class":100},[68,1063,626],{"class":138},[68,1065,142],{"class":100},[68,1067,145],{"class":138},[68,1069,153],{"class":100},[68,1071,1072,1074,1076,1078],{"class":70,"line":93},[68,1073,163],{"class":74},[68,1075,52],{"class":100},[68,1077,647],{"class":104},[68,1079,650],{"class":100},[68,1081,1082,1084,1086,1088,1090,1092],{"class":70,"line":120},[68,1083,163],{"class":74},[68,1085,52],{"class":100},[68,1087,168],{"class":104},[68,1089,101],{"class":100},[68,1091,173],{"class":138},[68,1093,591],{"class":100},[68,1095,1096,1098,1100,1102],{"class":70,"line":127},[68,1097,97],{"class":96},[68,1099,101],{"class":100},[68,1101,163],{"class":104},[68,1103,591],{"class":100},[14,1105,305],{},[59,1107,1109],{"className":61,"code":1108,"language":63,"meta":64,"style":64},"[1, 2, 3, 4]\n",[34,1110,1111],{"__ignoreMap":64},[68,1112,1113,1116,1118,1120,1122,1124,1126,1128,1131],{"class":70,"line":71},[68,1114,1115],{"class":100},"[",[68,1117,139],{"class":138},[68,1119,142],{"class":100},[68,1121,145],{"class":138},[68,1123,142],{"class":100},[68,1125,150],{"class":138},[68,1127,142],{"class":100},[68,1129,1130],{"class":138}," 4",[68,1132,153],{"class":100},[489,1134,1136],{"id":1135},"_5-use-the-right-method-for-the-object-type","5. Use the right method for the object type",[14,1138,1139],{},"Wrong:",[59,1141,1143],{"className":61,"code":1142,"language":63,"meta":64,"style":64},"items = [\"a\", \"b\", \"c\"]\nitems.upper()\n",[34,1144,1145,1177],{"__ignoreMap":64},[68,1146,1147,1149,1151,1153,1155,1157,1159,1161,1163,1165,1167,1169,1171,1173,1175],{"class":70,"line":71},[68,1148,331],{"class":74},[68,1150,79],{"class":78},[68,1152,135],{"class":100},[68,1154,338],{"class":82},[68,1156,46],{"class":86},[68,1158,338],{"class":82},[68,1160,142],{"class":100},[68,1162,83],{"class":82},[68,1164,349],{"class":86},[68,1166,338],{"class":82},[68,1168,142],{"class":100},[68,1170,83],{"class":82},[68,1172,358],{"class":86},[68,1174,338],{"class":82},[68,1176,153],{"class":100},[68,1178,1179,1181,1183,1185],{"class":70,"line":93},[68,1180,371],{"class":74},[68,1182,52],{"class":100},[68,1184,110],{"class":104},[68,1186,650],{"class":100},[14,1188,1189],{},"Correct:",[59,1191,1193],{"className":61,"code":1192,"language":63,"meta":64,"style":64},"items = [\"a\", \"b\", \"c\"]\nupper_items = [item.upper() for item in items]\nprint(upper_items)\n",[34,1194,1195,1227,1261],{"__ignoreMap":64},[68,1196,1197,1199,1201,1203,1205,1207,1209,1211,1213,1215,1217,1219,1221,1223,1225],{"class":70,"line":71},[68,1198,331],{"class":74},[68,1200,79],{"class":78},[68,1202,135],{"class":100},[68,1204,338],{"class":82},[68,1206,46],{"class":86},[68,1208,338],{"class":82},[68,1210,142],{"class":100},[68,1212,83],{"class":82},[68,1214,349],{"class":86},[68,1216,338],{"class":82},[68,1218,142],{"class":100},[68,1220,83],{"class":82},[68,1222,358],{"class":86},[68,1224,338],{"class":82},[68,1226,153],{"class":100},[68,1228,1229,1232,1234,1236,1239,1241,1243,1246,1250,1253,1256,1259],{"class":70,"line":93},[68,1230,1231],{"class":74},"upper_items ",[68,1233,79],{"class":78},[68,1235,135],{"class":100},[68,1237,1238],{"class":74},"item",[68,1240,52],{"class":100},[68,1242,110],{"class":104},[68,1244,1245],{"class":100},"()",[68,1247,1249],{"class":1248},"sVHd0"," for",[68,1251,1252],{"class":74}," item ",[68,1254,1255],{"class":1248},"in",[68,1257,1258],{"class":74}," items",[68,1260,153],{"class":100},[68,1262,1263,1265,1267,1270],{"class":70,"line":120},[68,1264,97],{"class":96},[68,1266,101],{"class":100},[68,1268,1269],{"class":104},"upper_items",[68,1271,591],{"class":100},[14,1273,305],{},[59,1275,1277],{"className":61,"code":1276,"language":63,"meta":64,"style":64},"['A', 'B', 'C']\n",[34,1278,1279],{"__ignoreMap":64},[68,1280,1281,1283,1285,1288,1290,1292,1294,1297,1299,1301,1303,1306,1308],{"class":70,"line":71},[68,1282,1115],{"class":100},[68,1284,400],{"class":82},[68,1286,1287],{"class":86},"A",[68,1289,400],{"class":82},[68,1291,142],{"class":100},[68,1293,394],{"class":82},[68,1295,1296],{"class":86},"B",[68,1298,400],{"class":82},[68,1300,142],{"class":100},[68,1302,394],{"class":82},[68,1304,1305],{"class":86},"C",[68,1307,400],{"class":82},[68,1309,153],{"class":100},[489,1311,1313],{"id":1312},"_6-fix-spelling-mistakes","6. Fix spelling mistakes",[14,1315,1139],{},[59,1317,1319],{"className":61,"code":1318,"language":63,"meta":64,"style":64},"text = \"hello\"\nprint(text.uppr())\n",[34,1320,1321,1333],{"__ignoreMap":64},[68,1322,1323,1325,1327,1329,1331],{"class":70,"line":71},[68,1324,277],{"class":74},[68,1326,79],{"class":78},[68,1328,83],{"class":82},[68,1330,284],{"class":86},[68,1332,90],{"class":82},[68,1334,1335,1337,1339,1341,1343,1346],{"class":70,"line":93},[68,1336,97],{"class":96},[68,1338,101],{"class":100},[68,1340,295],{"class":104},[68,1342,52],{"class":100},[68,1344,1345],{"class":104},"uppr",[68,1347,302],{"class":100},[14,1349,1189],{},[59,1351,1352],{"className":61,"code":270,"language":63,"meta":64,"style":64},[34,1353,1354,1366],{"__ignoreMap":64},[68,1355,1356,1358,1360,1362,1364],{"class":70,"line":71},[68,1357,277],{"class":74},[68,1359,79],{"class":78},[68,1361,83],{"class":82},[68,1363,284],{"class":86},[68,1365,90],{"class":82},[68,1367,1368,1370,1372,1374,1376,1378],{"class":70,"line":93},[68,1369,97],{"class":96},[68,1371,101],{"class":100},[68,1373,295],{"class":104},[68,1375,52],{"class":100},[68,1377,110],{"class":104},[68,1379,302],{"class":100},[14,1381,305],{},[59,1383,1384],{"className":61,"code":308,"language":63,"meta":64,"style":64},[34,1385,1386],{"__ignoreMap":64},[68,1387,1388],{"class":70,"line":71},[68,1389,308],{"class":315},[54,1391,1393],{"id":1392},"common-beginner-cases","Common beginner cases",[489,1395,1397],{"id":1396},"attributeerror-nonetype-object-has-no-attribute",[34,1398,1399],{},"AttributeError: 'NoneType' object has no attribute ...",[14,1401,1402,1403,52],{},"This usually means your variable is ",[34,1404,434],{},[14,1406,1407],{},"Common causes:",[21,1409,1410,1413,1422],{},[24,1411,1412],{},"A function did not return a value",[24,1414,1415,1416,459,1418,462,1420],{},"You used the result of ",[34,1417,36],{},[34,1419,255],{},[34,1421,458],{},[24,1423,1424,1425,1427],{},"A value was set to ",[34,1426,434],{}," earlier",[14,1429,1430,1431,52],{},"For a more focused guide, see ",[46,1432,1434],{"href":1433},"\u002Ferrors\u002Fattributeerror-nonetype-object-has-no-attribute-fix","AttributeError: 'NoneType' object has no attribute",[489,1436,1438],{"id":1437},"attributeerror-list-object-has-no-attribute",[34,1439,1440],{},"AttributeError: 'list' object has no attribute ...",[14,1442,1443],{},"This means you called a method that lists do not support.",[14,1445,1446],{},"Example:",[59,1448,1450],{"className":61,"code":1449,"language":63,"meta":64,"style":64},"items = [\"a\", \"b\"]\nprint(items.split(\",\"))\n",[34,1451,1452,1476],{"__ignoreMap":64},[68,1453,1454,1456,1458,1460,1462,1464,1466,1468,1470,1472,1474],{"class":70,"line":71},[68,1455,331],{"class":74},[68,1457,79],{"class":78},[68,1459,135],{"class":100},[68,1461,338],{"class":82},[68,1463,46],{"class":86},[68,1465,338],{"class":82},[68,1467,142],{"class":100},[68,1469,83],{"class":82},[68,1471,349],{"class":86},[68,1473,338],{"class":82},[68,1475,153],{"class":100},[68,1477,1478,1480,1482,1484,1486,1489,1491,1493,1495,1497],{"class":70,"line":93},[68,1479,97],{"class":96},[68,1481,101],{"class":100},[68,1483,371],{"class":104},[68,1485,52],{"class":100},[68,1487,1488],{"class":104},"split",[68,1490,101],{"class":100},[68,1492,338],{"class":82},[68,1494,142],{"class":86},[68,1496,338],{"class":82},[68,1498,684],{"class":100},[14,1500,1501,553],{},[34,1502,247],{},[14,1504,1505,1506,52],{},"See also ",[46,1507,1509],{"href":1508},"\u002Ferrors\u002Fattributeerror-list-object-has-no-attribute-fix","AttributeError: 'list' object has no attribute",[489,1511,1513],{"id":1512},"attributeerror-str-object-has-no-attribute",[34,1514,1515],{},"AttributeError: 'str' object has no attribute ...",[14,1517,1518],{},"This means you used a method that belongs to some other type.",[14,1520,1446],{},[59,1522,1524],{"className":61,"code":1523,"language":63,"meta":64,"style":64},"name = \"Python\"\nname.append(\"!\")\n",[34,1525,1526,1538],{"__ignoreMap":64},[68,1527,1528,1530,1532,1534,1536],{"class":70,"line":71},[68,1529,75],{"class":74},[68,1531,79],{"class":78},[68,1533,83],{"class":82},[68,1535,87],{"class":86},[68,1537,90],{"class":82},[68,1539,1540,1542,1544,1546,1548,1550,1553,1555],{"class":70,"line":93},[68,1541,105],{"class":74},[68,1543,52],{"class":100},[68,1545,168],{"class":104},[68,1547,101],{"class":100},[68,1549,338],{"class":82},[68,1551,1552],{"class":86},"!",[68,1554,338],{"class":82},[68,1556,591],{"class":100},[14,1558,1559,1560,52],{},"Strings do not have ",[34,1561,36],{},[14,1563,1505,1564,52],{},[46,1565,1567],{"href":1566},"\u002Ferrors\u002Fattributeerror-str-object-has-no-attribute-fix","AttributeError: 'str' object has no attribute",[489,1569,1571],{"id":1570},"attributeerror-when-importing-a-module-and-calling-the-wrong-name","AttributeError when importing a module and calling the wrong name",[14,1573,1574],{},"Sometimes the object is a module, but the attribute name is wrong.",[14,1576,1446],{},[59,1578,1580],{"className":61,"code":1579,"language":63,"meta":64,"style":64},"import math\n\nprint(math.PI)\n",[34,1581,1582,1590,1594],{"__ignoreMap":64},[68,1583,1584,1587],{"class":70,"line":71},[68,1585,1586],{"class":1248},"import",[68,1588,1589],{"class":74}," math\n",[68,1591,1592],{"class":70,"line":93},[68,1593,124],{"emptyLinePlaceholder":123},[68,1595,1596,1598,1600,1603,1605,1609],{"class":70,"line":120},[68,1597,97],{"class":96},[68,1599,101],{"class":100},[68,1601,1602],{"class":104},"math",[68,1604,52],{"class":100},[68,1606,1608],{"class":1607},"swQdS","PI",[68,1610,591],{"class":100},[14,1612,1613,1614,52],{},"This fails because the correct name is ",[34,1615,1616],{},"math.pi",[14,1618,1044],{},[59,1620,1622],{"className":61,"code":1621,"language":63,"meta":64,"style":64},"import math\n\nprint(math.pi)\n",[34,1623,1624,1630,1634],{"__ignoreMap":64},[68,1625,1626,1628],{"class":70,"line":71},[68,1627,1586],{"class":1248},[68,1629,1589],{"class":74},[68,1631,1632],{"class":70,"line":93},[68,1633,124],{"emptyLinePlaceholder":123},[68,1635,1636,1638,1640,1642,1644,1648],{"class":70,"line":120},[68,1637,97],{"class":96},[68,1639,101],{"class":100},[68,1641,1602],{"class":104},[68,1643,52],{"class":100},[68,1645,1647],{"class":1646},"skxfh","pi",[68,1649,591],{"class":100},[14,1651,305],{},[59,1653,1655],{"className":61,"code":1654,"language":63,"meta":64,"style":64},"3.141592653589793\n",[34,1656,1657],{"__ignoreMap":64},[68,1658,1659],{"class":70,"line":71},[68,1660,1654],{"class":138},[54,1662,1664],{"id":1663},"step-by-step-debugging-checklist","Step-by-step debugging checklist",[14,1666,1667],{},"When you see this error, work through these steps:",[1669,1670,1671,1674,1677,1683,1686,1689],"ol",{},[24,1672,1673],{},"Find the line named in the traceback",[24,1675,1676],{},"Look at the value before the dot",[24,1678,1679,1680],{},"Print ",[34,1681,1682],{},"type(value)",[24,1684,1685],{},"Check whether that type supports the attribute",[24,1687,1688],{},"Trace back where the value came from",[24,1690,1691],{},"Confirm the function or method returned what you expected",[14,1693,1694],{},"Useful debugging commands:",[59,1696,1698],{"className":61,"code":1697,"language":63,"meta":64,"style":64},"print(value)\nprint(type(value))\nprint(dir(value))\nhelp(type(value))\n",[34,1699,1700,1710,1724,1738],{"__ignoreMap":64},[68,1701,1702,1704,1706,1708],{"class":70,"line":71},[68,1703,97],{"class":96},[68,1705,101],{"class":100},[68,1707,580],{"class":104},[68,1709,591],{"class":100},[68,1711,1712,1714,1716,1718,1720,1722],{"class":70,"line":93},[68,1713,97],{"class":96},[68,1715,101],{"class":100},[68,1717,840],{"class":389},[68,1719,101],{"class":100},[68,1721,580],{"class":104},[68,1723,684],{"class":100},[68,1725,1726,1728,1730,1732,1734,1736],{"class":70,"line":120},[68,1727,97],{"class":96},[68,1729,101],{"class":100},[68,1731,963],{"class":96},[68,1733,101],{"class":100},[68,1735,580],{"class":104},[68,1737,684],{"class":100},[68,1739,1740,1743,1745,1747,1749,1751],{"class":70,"line":127},[68,1741,1742],{"class":96},"help",[68,1744,101],{"class":100},[68,1746,840],{"class":389},[68,1748,101],{"class":100},[68,1750,580],{"class":104},[68,1752,684],{"class":100},[14,1754,1755,1756,52],{},"If you want a beginner-friendly process for debugging, read the ",[46,1757,1759],{"href":1758},"\u002Fhow-to\u002Fhow-to-debug-python-code-beginner-guide\u002F","beginner guide to debugging Python code",[54,1761,1763],{"id":1762},"faq","FAQ",[489,1765,1767],{"id":1766},"what-is-an-attribute-in-python","What is an attribute in Python?",[14,1769,1770,1771,1774,1775,52],{},"An attribute is something attached to an object, such as a variable or method. You access it with dot notation like ",[34,1772,1773],{},"obj.name"," or ",[34,1776,1777],{},"obj.method()",[489,1779,1781],{"id":1780},"why-do-i-get-this-error-with-none","Why do I get this error with None?",[14,1783,1784,1785,1787,1788,1774,1790,1792,1793,1795],{},"Because ",[34,1786,434],{}," is a special value, and many methods like ",[34,1789,36],{},[34,1791,247],{}," do not exist on it. Often a function returned ",[34,1794,434],{}," instead of the value you expected.",[489,1797,1799],{"id":1798},"how-do-i-know-which-methods-an-object-has","How do I know which methods an object has?",[14,1801,789,1802,1805],{},[34,1803,1804],{},"dir(obj)"," to list available attributes and methods, or check the official documentation for that object type.",[489,1807,1809],{"id":1808},"is-this-the-same-as-nameerror","Is this the same as NameError?",[14,1811,1812,1813,1816,1817,1819],{},"No. ",[34,1814,1815],{},"NameError"," means Python does not know the variable name at all. ",[34,1818,218],{}," means the variable exists, but the attribute after the dot does not.",[54,1821,1823],{"id":1822},"see-also","See also",[21,1825,1826,1832,1836,1840,1844,1848,1856],{},[24,1827,1828],{},[46,1829,1831],{"href":1830},"\u002Ferrors\u002Fattributeerror-in-python-causes-and-fixes\u002F","AttributeError in Python: causes and fixes",[24,1833,1834],{},[46,1835,1509],{"href":1508},[24,1837,1838],{},[46,1839,1567],{"href":1566},[24,1841,1842],{},[46,1843,1434],{"href":1433},[24,1845,1846],{},[46,1847,483],{"href":482},[24,1849,1850],{},[46,1851,1852,1853,1855],{"href":48},"Python ",[34,1854,51],{}," function explained",[24,1857,1858],{},[46,1859,1852,1860,1855],{"href":934},[34,1861,928],{},[1863,1864,1865],"style",{},"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 .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 .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .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 pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .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 .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--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 .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}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 .swQdS, html code.shiki .swQdS{--shiki-light:#E53935;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}",{"title":64,"searchDepth":93,"depth":93,"links":1867},[1868,1869,1870,1871,1877,1886,1892,1893,1899],{"id":56,"depth":93,"text":57},{"id":212,"depth":93,"text":213},{"id":416,"depth":93,"text":417},{"id":486,"depth":93,"text":487,"children":1872},[1873,1874,1876],{"id":491,"depth":120,"text":492},{"id":556,"depth":120,"text":1875},"Calling append() on None",{"id":730,"depth":120,"text":731},{"id":778,"depth":93,"text":779,"children":1878},[1879,1880,1881,1883,1884,1885],{"id":785,"depth":120,"text":786},{"id":877,"depth":120,"text":878},{"id":924,"depth":120,"text":1882},"3. Inspect available attributes with dir()",{"id":975,"depth":120,"text":976},{"id":1135,"depth":120,"text":1136},{"id":1312,"depth":120,"text":1313},{"id":1392,"depth":93,"text":1393,"children":1887},[1888,1889,1890,1891],{"id":1396,"depth":120,"text":1399},{"id":1437,"depth":120,"text":1440},{"id":1512,"depth":120,"text":1515},{"id":1570,"depth":120,"text":1571},{"id":1663,"depth":93,"text":1664},{"id":1762,"depth":93,"text":1763,"children":1894},[1895,1896,1897,1898],{"id":1766,"depth":120,"text":1767},{"id":1780,"depth":120,"text":1781},{"id":1798,"depth":120,"text":1799},{"id":1808,"depth":120,"text":1809},{"id":1822,"depth":93,"text":1823},"Master attributeerror object has no attribute fix in our comprehensive Python beginner guide.","md",{},"\u002Ferrors\u002Fattributeerror-object-has-no-attribute-fix",{"title":5,"description":1900},"errors\u002Fattributeerror-object-has-no-attribute-fix","9lky8kZG5OC3E1Vfd73LfnyZlP_GC-XvDxf2bT1ycOQ",1777585495771]