[{"data":1,"prerenderedAt":1739},["ShallowReactive",2],{"doc-\u002Freference\u002Fpython-string-lower-method":3},{"id":4,"title":5,"body":6,"description":1732,"extension":1733,"meta":1734,"navigation":248,"path":1735,"seo":1736,"stem":1737,"__hash__":1738},"content\u002Freference\u002Fpython-string-lower-method.md","Python String lower() Method",{"type":7,"value":8,"toc":1699},"minimark",[9,19,26,29,45,120,130,138,143,146,162,175,179,182,198,201,212,215,283,287,290,355,358,377,380,393,396,443,447,454,457,460,528,540,628,632,637,640,654,657,746,749,810,822,880,884,891,897,904,948,951,998,1002,1007,1015,1018,1050,1053,1056,1088,1092,1095,1097,1137,1139,1182,1189,1194,1196,1227,1233,1236,1288,1292,1295,1371,1384,1387,1444,1452,1458,1466,1472,1481,1488,1506,1508,1564,1574,1578,1585,1588,1594,1600,1607,1610,1617,1623,1632,1640,1644,1695],[10,11,13,14,18],"h1",{"id":12},"python-string-lower-method","Python String ",[15,16,17],"code",{},"lower()"," Method",[20,21,22,23,25],"p",{},"The Python string ",[15,24,17],{}," method returns a lowercase version of a string.",[20,27,28],{},"It is useful when you want to:",[30,31,32,36,39,42],"ul",{},[33,34,35],"li",{},"convert text to lowercase",[33,37,38],{},"compare text without case differences",[33,40,41],{},"clean up user input",[33,43,44],{},"make simple text matching easier",[46,47,52],"pre",{"className":48,"code":49,"language":50,"meta":51,"style":51},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","text = \"Hello WORLD\"\nresult = text.lower()\nprint(result)  # hello world\n","python","",[15,53,54,78,100],{"__ignoreMap":51},[55,56,59,63,67,71,75],"span",{"class":57,"line":58},"line",1,[55,60,62],{"class":61},"su5hD","text ",[55,64,66],{"class":65},"smGrS","=",[55,68,70],{"class":69},"sjJ54"," \"",[55,72,74],{"class":73},"s_sjI","Hello WORLD",[55,76,77],{"class":69},"\"\n",[55,79,81,84,86,89,93,97],{"class":57,"line":80},2,[55,82,83],{"class":61},"result ",[55,85,66],{"class":65},[55,87,88],{"class":61}," text",[55,90,92],{"class":91},"sP7_E",".",[55,94,96],{"class":95},"slqww","lower",[55,98,99],{"class":91},"()\n",[55,101,103,107,110,113,116],{"class":57,"line":102},3,[55,104,106],{"class":105},"sptTA","print",[55,108,109],{"class":91},"(",[55,111,112],{"class":95},"result",[55,114,115],{"class":91},")",[55,117,119],{"class":118},"sutJx","  # hello world\n",[20,121,122,126,127,129],{},[123,124,125],"strong",{},"Important:"," ",[15,128,17],{}," returns a new string. It does not change the original string in place.",[131,132,134,135,137],"h2",{"id":133},"what-lower-does","What ",[15,136,17],{}," does",[20,139,140,142],{},[15,141,17],{}," is a string method that changes uppercase letters to lowercase letters.",[20,144,145],{},"Key points:",[30,147,148,153,156,159],{},[33,149,150,152],{},[15,151,17],{}," returns a lowercase version of a string",[33,154,155],{},"It works on string objects",[33,157,158],{},"It creates and returns a new string",[33,160,161],{},"The original string stays unchanged",[20,163,164,165,170,171,92],{},"If you are new to strings, see ",[166,167,169],"a",{"href":168},"\u002Fglossary\u002Fwhat-is-a-string-in-python\u002F","what a string is in Python"," or learn more in ",[166,172,174],{"href":173},"\u002Flearn\u002Fpython-strings-explained-basics-and-examples\u002F","Python strings explained",[131,176,178],{"id":177},"basic-syntax","Basic syntax",[20,180,181],{},"The syntax is:",[46,183,185],{"className":48,"code":184,"language":50,"meta":51,"style":51},"string.lower()\n",[15,186,187],{"__ignoreMap":51},[55,188,189,192,194,196],{"class":57,"line":58},[55,190,191],{"class":61},"string",[55,193,92],{"class":91},[55,195,96],{"class":95},[55,197,99],{"class":91},[20,199,200],{},"Important details:",[30,202,203,206,209],{},[33,204,205],{},"It takes no arguments",[33,207,208],{},"You call it directly on a string",[33,210,211],{},"You can use it on a string literal or a string variable",[20,213,214],{},"Example:",[46,216,218],{"className":48,"code":217,"language":50,"meta":51,"style":51},"print(\"HELLO\".lower())  # hello\n\nname = \"PyThOn\"\nprint(name.lower())  # python\n",[15,219,220,244,250,264],{"__ignoreMap":51},[55,221,222,224,226,229,232,234,236,238,241],{"class":57,"line":58},[55,223,106],{"class":105},[55,225,109],{"class":91},[55,227,228],{"class":69},"\"",[55,230,231],{"class":73},"HELLO",[55,233,228],{"class":69},[55,235,92],{"class":91},[55,237,96],{"class":95},[55,239,240],{"class":91},"())",[55,242,243],{"class":118},"  # hello\n",[55,245,246],{"class":57,"line":80},[55,247,249],{"emptyLinePlaceholder":248},true,"\n",[55,251,252,255,257,259,262],{"class":57,"line":102},[55,253,254],{"class":61},"name ",[55,256,66],{"class":65},[55,258,70],{"class":69},[55,260,261],{"class":73},"PyThOn",[55,263,77],{"class":69},[55,265,267,269,271,274,276,278,280],{"class":57,"line":266},4,[55,268,106],{"class":105},[55,270,109],{"class":91},[55,272,273],{"class":95},"name",[55,275,92],{"class":91},[55,277,96],{"class":95},[55,279,240],{"class":91},[55,281,282],{"class":118},"  # python\n",[131,284,286],{"id":285},"simple-example","Simple example",[20,288,289],{},"Here is a basic example with a variable:",[46,291,293],{"className":48,"code":292,"language":50,"meta":51,"style":51},"text = \"Hello WORLD\"\n\nlower_text = text.lower()\n\nprint(lower_text)\nprint(text)\n",[15,294,295,307,311,326,330,343],{"__ignoreMap":51},[55,296,297,299,301,303,305],{"class":57,"line":58},[55,298,62],{"class":61},[55,300,66],{"class":65},[55,302,70],{"class":69},[55,304,74],{"class":73},[55,306,77],{"class":69},[55,308,309],{"class":57,"line":80},[55,310,249],{"emptyLinePlaceholder":248},[55,312,313,316,318,320,322,324],{"class":57,"line":102},[55,314,315],{"class":61},"lower_text ",[55,317,66],{"class":65},[55,319,88],{"class":61},[55,321,92],{"class":91},[55,323,96],{"class":95},[55,325,99],{"class":91},[55,327,328],{"class":57,"line":266},[55,329,249],{"emptyLinePlaceholder":248},[55,331,333,335,337,340],{"class":57,"line":332},5,[55,334,106],{"class":105},[55,336,109],{"class":91},[55,338,339],{"class":95},"lower_text",[55,341,342],{"class":91},")\n",[55,344,346,348,350,353],{"class":57,"line":345},6,[55,347,106],{"class":105},[55,349,109],{"class":91},[55,351,352],{"class":95},"text",[55,354,342],{"class":91},[20,356,357],{},"Output:",[46,359,361],{"className":48,"code":360,"language":50,"meta":51,"style":51},"hello world\nHello WORLD\n",[15,362,363,368],{"__ignoreMap":51},[55,364,365],{"class":57,"line":58},[55,366,367],{"class":61},"hello world\n",[55,369,370,373],{"class":57,"line":80},[55,371,372],{"class":61},"Hello ",[55,374,376],{"class":375},"s_hVV","WORLD\n",[20,378,379],{},"This shows two things:",[30,381,382,387],{},[33,383,384,386],{},[15,385,17],{}," returns the lowercase result",[33,388,389,390,392],{},"the original ",[15,391,352],{}," variable does not change unless you reassign it",[20,394,395],{},"If you want to keep the lowercase version in the same variable, reassign it:",[46,397,399],{"className":48,"code":398,"language":50,"meta":51,"style":51},"text = \"Hello WORLD\"\ntext = text.lower()\n\nprint(text)  # hello world\n",[15,400,401,413,427,431],{"__ignoreMap":51},[55,402,403,405,407,409,411],{"class":57,"line":58},[55,404,62],{"class":61},[55,406,66],{"class":65},[55,408,70],{"class":69},[55,410,74],{"class":73},[55,412,77],{"class":69},[55,414,415,417,419,421,423,425],{"class":57,"line":80},[55,416,62],{"class":61},[55,418,66],{"class":65},[55,420,88],{"class":61},[55,422,92],{"class":91},[55,424,96],{"class":95},[55,426,99],{"class":91},[55,428,429],{"class":57,"line":102},[55,430,249],{"emptyLinePlaceholder":248},[55,432,433,435,437,439,441],{"class":57,"line":266},[55,434,106],{"class":105},[55,436,109],{"class":91},[55,438,352],{"class":95},[55,440,115],{"class":91},[55,442,119],{"class":118},[131,444,446],{"id":445},"return-value","Return value",[20,448,449,451,452,92],{},[15,450,17],{}," returns a ",[123,453,191],{},[20,455,456],{},"That means you can store the result in a variable, print it, or use it in comparisons.",[20,458,459],{},"A common beginner use case is comparing text in a case-insensitive way:",[46,461,463],{"className":48,"code":462,"language":50,"meta":51,"style":51},"answer = \"YES\"\n\nif answer.lower() == \"yes\":\n    print(\"Correct\")\n",[15,464,465,479,483,512],{"__ignoreMap":51},[55,466,467,470,472,474,477],{"class":57,"line":58},[55,468,469],{"class":61},"answer ",[55,471,66],{"class":65},[55,473,70],{"class":69},[55,475,476],{"class":73},"YES",[55,478,77],{"class":69},[55,480,481],{"class":57,"line":80},[55,482,249],{"emptyLinePlaceholder":248},[55,484,485,489,492,494,496,499,502,504,507,509],{"class":57,"line":102},[55,486,488],{"class":487},"sVHd0","if",[55,490,491],{"class":61}," answer",[55,493,92],{"class":91},[55,495,96],{"class":95},[55,497,498],{"class":91},"()",[55,500,501],{"class":65}," ==",[55,503,70],{"class":69},[55,505,506],{"class":73},"yes",[55,508,228],{"class":69},[55,510,511],{"class":91},":\n",[55,513,514,517,519,521,524,526],{"class":57,"line":266},[55,515,516],{"class":105},"    print",[55,518,109],{"class":91},[55,520,228],{"class":69},[55,522,523],{"class":73},"Correct",[55,525,228],{"class":69},[55,527,342],{"class":91},[20,529,530,531,539],{},"This is especially useful with ",[166,532,534,535,538],{"href":533},"\u002Freference\u002Fpython-input-function-explained\u002F","the ",[15,536,537],{},"input()"," function",":",[46,541,543],{"className":48,"code":542,"language":50,"meta":51,"style":51},"answer = input(\"Type yes or no: \")\n\nif answer.lower() == \"yes\":\n    print(\"You typed yes\")\nelse:\n    print(\"You typed something else\")\n",[15,544,545,565,569,591,606,613],{"__ignoreMap":51},[55,546,547,549,551,554,556,558,561,563],{"class":57,"line":58},[55,548,469],{"class":61},[55,550,66],{"class":65},[55,552,553],{"class":105}," input",[55,555,109],{"class":91},[55,557,228],{"class":69},[55,559,560],{"class":73},"Type yes or no: ",[55,562,228],{"class":69},[55,564,342],{"class":91},[55,566,567],{"class":57,"line":80},[55,568,249],{"emptyLinePlaceholder":248},[55,570,571,573,575,577,579,581,583,585,587,589],{"class":57,"line":102},[55,572,488],{"class":487},[55,574,491],{"class":61},[55,576,92],{"class":91},[55,578,96],{"class":95},[55,580,498],{"class":91},[55,582,501],{"class":65},[55,584,70],{"class":69},[55,586,506],{"class":73},[55,588,228],{"class":69},[55,590,511],{"class":91},[55,592,593,595,597,599,602,604],{"class":57,"line":266},[55,594,516],{"class":105},[55,596,109],{"class":91},[55,598,228],{"class":69},[55,600,601],{"class":73},"You typed yes",[55,603,228],{"class":69},[55,605,342],{"class":91},[55,607,608,611],{"class":57,"line":332},[55,609,610],{"class":487},"else",[55,612,511],{"class":91},[55,614,615,617,619,621,624,626],{"class":57,"line":345},[55,616,516],{"class":105},[55,618,109],{"class":91},[55,620,228],{"class":69},[55,622,623],{"class":73},"You typed something else",[55,625,228],{"class":69},[55,627,342],{"class":91},[131,629,631],{"id":630},"common-use-cases","Common use cases",[20,633,634,636],{},[15,635,17],{}," is often used to normalize text before working with it.",[20,638,639],{},"Common examples:",[30,641,642,645,648,651],{},[33,643,644],{},"Normalize user input before comparison",[33,646,647],{},"Make text matching easier",[33,649,650],{},"Prepare text for simple searches",[33,652,653],{},"Clean mixed-case data",[20,655,656],{},"Example: checking user input",[46,658,660],{"className":48,"code":659,"language":50,"meta":51,"style":51},"color = input(\"What is your favorite color? \")\n\nif color.lower() == \"blue\":\n    print(\"Nice choice!\")\nelse:\n    print(\"Got it.\")\n",[15,661,662,682,686,710,725,731],{"__ignoreMap":51},[55,663,664,667,669,671,673,675,678,680],{"class":57,"line":58},[55,665,666],{"class":61},"color ",[55,668,66],{"class":65},[55,670,553],{"class":105},[55,672,109],{"class":91},[55,674,228],{"class":69},[55,676,677],{"class":73},"What is your favorite color? ",[55,679,228],{"class":69},[55,681,342],{"class":91},[55,683,684],{"class":57,"line":80},[55,685,249],{"emptyLinePlaceholder":248},[55,687,688,690,693,695,697,699,701,703,706,708],{"class":57,"line":102},[55,689,488],{"class":487},[55,691,692],{"class":61}," color",[55,694,92],{"class":91},[55,696,96],{"class":95},[55,698,498],{"class":91},[55,700,501],{"class":65},[55,702,70],{"class":69},[55,704,705],{"class":73},"blue",[55,707,228],{"class":69},[55,709,511],{"class":91},[55,711,712,714,716,718,721,723],{"class":57,"line":266},[55,713,516],{"class":105},[55,715,109],{"class":91},[55,717,228],{"class":69},[55,719,720],{"class":73},"Nice choice!",[55,722,228],{"class":69},[55,724,342],{"class":91},[55,726,727,729],{"class":57,"line":332},[55,728,610],{"class":487},[55,730,511],{"class":91},[55,732,733,735,737,739,742,744],{"class":57,"line":345},[55,734,516],{"class":105},[55,736,109],{"class":91},[55,738,228],{"class":69},[55,740,741],{"class":73},"Got it.",[55,743,228],{"class":69},[55,745,342],{"class":91},[20,747,748],{},"Example: simple search",[46,750,752],{"className":48,"code":751,"language":50,"meta":51,"style":51},"message = \"Python Is Fun\"\n\nif \"python\" in message.lower():\n    print(\"Found it\")\n",[15,753,754,768,772,795],{"__ignoreMap":51},[55,755,756,759,761,763,766],{"class":57,"line":58},[55,757,758],{"class":61},"message ",[55,760,66],{"class":65},[55,762,70],{"class":69},[55,764,765],{"class":73},"Python Is Fun",[55,767,77],{"class":69},[55,769,770],{"class":57,"line":80},[55,771,249],{"emptyLinePlaceholder":248},[55,773,774,776,778,780,782,785,788,790,792],{"class":57,"line":102},[55,775,488],{"class":487},[55,777,70],{"class":69},[55,779,50],{"class":73},[55,781,228],{"class":69},[55,783,784],{"class":65}," in",[55,786,787],{"class":61}," message",[55,789,92],{"class":91},[55,791,96],{"class":95},[55,793,794],{"class":91},"():\n",[55,796,797,799,801,803,806,808],{"class":57,"line":266},[55,798,516],{"class":105},[55,800,109],{"class":91},[55,802,228],{"class":69},[55,804,805],{"class":73},"Found it",[55,807,228],{"class":69},[55,809,342],{"class":91},[20,811,812,813,815,816,539],{},"If you also need to remove extra spaces, ",[15,814,17],{}," is often used with ",[166,817,819],{"href":818},"\u002Freference\u002Fpython-string-strip-method\u002F",[15,820,821],{},"strip()",[46,823,825],{"className":48,"code":824,"language":50,"meta":51,"style":51},"name = \"  ALICE  \"\nclean_name = name.strip().lower()\n\nprint(clean_name)  # alice\n",[15,826,827,840,862,866],{"__ignoreMap":51},[55,828,829,831,833,835,838],{"class":57,"line":58},[55,830,254],{"class":61},[55,832,66],{"class":65},[55,834,70],{"class":69},[55,836,837],{"class":73},"  ALICE  ",[55,839,77],{"class":69},[55,841,842,845,847,850,852,855,858,860],{"class":57,"line":80},[55,843,844],{"class":61},"clean_name ",[55,846,66],{"class":65},[55,848,849],{"class":61}," name",[55,851,92],{"class":91},[55,853,854],{"class":95},"strip",[55,856,857],{"class":91},"().",[55,859,96],{"class":95},[55,861,99],{"class":91},[55,863,864],{"class":57,"line":102},[55,865,249],{"emptyLinePlaceholder":248},[55,867,868,870,872,875,877],{"class":57,"line":266},[55,869,106],{"class":105},[55,871,109],{"class":91},[55,873,874],{"class":95},"clean_name",[55,876,115],{"class":91},[55,878,879],{"class":118},"  # alice\n",[131,881,883],{"id":882},"important-beginner-note","Important beginner note",[20,885,886,887,890],{},"Strings are ",[123,888,889],{},"immutable"," in Python.",[20,892,893,894,896],{},"That means a string cannot be changed in place. Methods like ",[15,895,17],{}," do not edit the original string. They return a new one.",[20,898,899,900,903],{},"So this does ",[123,901,902],{},"not"," update the original variable:",[46,905,907],{"className":48,"code":906,"language":50,"meta":51,"style":51},"text = \"HELLO\"\ntext.lower()\n\nprint(text)  # HELLO\n",[15,908,909,921,931,935],{"__ignoreMap":51},[55,910,911,913,915,917,919],{"class":57,"line":58},[55,912,62],{"class":61},[55,914,66],{"class":65},[55,916,70],{"class":69},[55,918,231],{"class":73},[55,920,77],{"class":69},[55,922,923,925,927,929],{"class":57,"line":80},[55,924,352],{"class":61},[55,926,92],{"class":91},[55,928,96],{"class":95},[55,930,99],{"class":91},[55,932,933],{"class":57,"line":102},[55,934,249],{"emptyLinePlaceholder":248},[55,936,937,939,941,943,945],{"class":57,"line":266},[55,938,106],{"class":105},[55,940,109],{"class":91},[55,942,352],{"class":95},[55,944,115],{"class":91},[55,946,947],{"class":118},"  # HELLO\n",[20,949,950],{},"To keep the lowercase version, save the result:",[46,952,954],{"className":48,"code":953,"language":50,"meta":51,"style":51},"text = \"HELLO\"\ntext = text.lower()\n\nprint(text)  # hello\n",[15,955,956,968,982,986],{"__ignoreMap":51},[55,957,958,960,962,964,966],{"class":57,"line":58},[55,959,62],{"class":61},[55,961,66],{"class":65},[55,963,70],{"class":69},[55,965,231],{"class":73},[55,967,77],{"class":69},[55,969,970,972,974,976,978,980],{"class":57,"line":80},[55,971,62],{"class":61},[55,973,66],{"class":65},[55,975,88],{"class":61},[55,977,92],{"class":91},[55,979,96],{"class":95},[55,981,99],{"class":91},[55,983,984],{"class":57,"line":102},[55,985,249],{"emptyLinePlaceholder":248},[55,987,988,990,992,994,996],{"class":57,"line":266},[55,989,106],{"class":105},[55,991,109],{"class":91},[55,993,352],{"class":95},[55,995,115],{"class":91},[55,997,243],{"class":118},[131,999,1001],{"id":1000},"common-mistakes","Common mistakes",[1003,1004,1006],"h3",{"id":1005},"forgetting-parentheses","Forgetting parentheses",[20,1008,1009,1010,1012,1013,92],{},"A very common mistake is writing ",[15,1011,96],{}," instead of ",[15,1014,17],{},[20,1016,1017],{},"Wrong:",[46,1019,1021],{"className":48,"code":1020,"language":50,"meta":51,"style":51},"text = \"HELLO\"\nprint(text.lower)\n",[15,1022,1023,1035],{"__ignoreMap":51},[55,1024,1025,1027,1029,1031,1033],{"class":57,"line":58},[55,1026,62],{"class":61},[55,1028,66],{"class":65},[55,1030,70],{"class":69},[55,1032,231],{"class":73},[55,1034,77],{"class":69},[55,1036,1037,1039,1041,1043,1045,1048],{"class":57,"line":80},[55,1038,106],{"class":105},[55,1040,109],{"class":91},[55,1042,352],{"class":95},[55,1044,92],{"class":91},[55,1046,96],{"class":1047},"skxfh",[55,1049,342],{"class":91},[20,1051,1052],{},"This prints the method itself, not the lowercase string.",[20,1054,1055],{},"Correct:",[46,1057,1059],{"className":48,"code":1058,"language":50,"meta":51,"style":51},"text = \"HELLO\"\nprint(text.lower())\n",[15,1060,1061,1073],{"__ignoreMap":51},[55,1062,1063,1065,1067,1069,1071],{"class":57,"line":58},[55,1064,62],{"class":61},[55,1066,66],{"class":65},[55,1068,70],{"class":69},[55,1070,231],{"class":73},[55,1072,77],{"class":69},[55,1074,1075,1077,1079,1081,1083,1085],{"class":57,"line":80},[55,1076,106],{"class":105},[55,1078,109],{"class":91},[55,1080,352],{"class":95},[55,1082,92],{"class":91},[55,1084,96],{"class":95},[55,1086,1087],{"class":91},"())\n",[1003,1089,1091],{"id":1090},"not-saving-the-result","Not saving the result",[20,1093,1094],{},"Another common mistake is expecting the original variable to change automatically.",[20,1096,1017],{},[46,1098,1100],{"className":48,"code":1099,"language":50,"meta":51,"style":51},"text = \"HELLO\"\ntext.lower()\nprint(text)  # still HELLO\n",[15,1101,1102,1114,1124],{"__ignoreMap":51},[55,1103,1104,1106,1108,1110,1112],{"class":57,"line":58},[55,1105,62],{"class":61},[55,1107,66],{"class":65},[55,1109,70],{"class":69},[55,1111,231],{"class":73},[55,1113,77],{"class":69},[55,1115,1116,1118,1120,1122],{"class":57,"line":80},[55,1117,352],{"class":61},[55,1119,92],{"class":91},[55,1121,96],{"class":95},[55,1123,99],{"class":91},[55,1125,1126,1128,1130,1132,1134],{"class":57,"line":102},[55,1127,106],{"class":105},[55,1129,109],{"class":91},[55,1131,352],{"class":95},[55,1133,115],{"class":91},[55,1135,1136],{"class":118},"  # still HELLO\n",[20,1138,1055],{},[46,1140,1142],{"className":48,"code":1141,"language":50,"meta":51,"style":51},"text = \"HELLO\"\ntext = text.lower()\nprint(text)  # hello\n",[15,1143,1144,1156,1170],{"__ignoreMap":51},[55,1145,1146,1148,1150,1152,1154],{"class":57,"line":58},[55,1147,62],{"class":61},[55,1149,66],{"class":65},[55,1151,70],{"class":69},[55,1153,231],{"class":73},[55,1155,77],{"class":69},[55,1157,1158,1160,1162,1164,1166,1168],{"class":57,"line":80},[55,1159,62],{"class":61},[55,1161,66],{"class":65},[55,1163,88],{"class":61},[55,1165,92],{"class":91},[55,1167,96],{"class":95},[55,1169,99],{"class":91},[55,1171,1172,1174,1176,1178,1180],{"class":57,"line":102},[55,1173,106],{"class":105},[55,1175,109],{"class":91},[55,1177,352],{"class":95},[55,1179,115],{"class":91},[55,1181,243],{"class":118},[1003,1183,1185,1186,1188],{"id":1184},"using-lower-on-a-non-string-value","Using ",[15,1187,17],{}," on a non-string value",[20,1190,1191,1193],{},[15,1192,17],{}," only works on strings.",[20,1195,1017],{},[46,1197,1199],{"className":48,"code":1198,"language":50,"meta":51,"style":51},"number = 123\nprint(number.lower())\n",[15,1200,1201,1212],{"__ignoreMap":51},[55,1202,1203,1206,1208],{"class":57,"line":58},[55,1204,1205],{"class":61},"number ",[55,1207,66],{"class":65},[55,1209,1211],{"class":1210},"srdBf"," 123\n",[55,1213,1214,1216,1218,1221,1223,1225],{"class":57,"line":80},[55,1215,106],{"class":105},[55,1217,109],{"class":91},[55,1219,1220],{"class":95},"number",[55,1222,92],{"class":91},[55,1224,96],{"class":95},[55,1226,1087],{"class":91},[20,1228,1229,1230,1232],{},"This causes an error because integers do not have a ",[15,1231,17],{}," method.",[20,1234,1235],{},"You can check the type first:",[46,1237,1239],{"className":48,"code":1238,"language":50,"meta":51,"style":51},"text = \"HELLO\"\n\nprint(type(text))\nprint(text.lower())\n",[15,1240,1241,1253,1257,1274],{"__ignoreMap":51},[55,1242,1243,1245,1247,1249,1251],{"class":57,"line":58},[55,1244,62],{"class":61},[55,1246,66],{"class":65},[55,1248,70],{"class":69},[55,1250,231],{"class":73},[55,1252,77],{"class":69},[55,1254,1255],{"class":57,"line":80},[55,1256,249],{"emptyLinePlaceholder":248},[55,1258,1259,1261,1263,1267,1269,1271],{"class":57,"line":102},[55,1260,106],{"class":105},[55,1262,109],{"class":91},[55,1264,1266],{"class":1265},"sZMiF","type",[55,1268,109],{"class":91},[55,1270,352],{"class":95},[55,1272,1273],{"class":91},"))\n",[55,1275,1276,1278,1280,1282,1284,1286],{"class":57,"line":266},[55,1277,106],{"class":105},[55,1279,109],{"class":91},[55,1281,352],{"class":95},[55,1283,92],{"class":91},[55,1285,96],{"class":95},[55,1287,1087],{"class":91},[1003,1289,1291],{"id":1290},"comparing-text-without-normalizing-case","Comparing text without normalizing case",[20,1293,1294],{},"This can cause unexpected results:",[46,1296,1298],{"className":48,"code":1297,"language":50,"meta":51,"style":51},"answer = \"Yes\"\n\nif answer == \"yes\":\n    print(\"Match\")\nelse:\n    print(\"No match\")\n",[15,1299,1300,1313,1317,1335,1350,1356],{"__ignoreMap":51},[55,1301,1302,1304,1306,1308,1311],{"class":57,"line":58},[55,1303,469],{"class":61},[55,1305,66],{"class":65},[55,1307,70],{"class":69},[55,1309,1310],{"class":73},"Yes",[55,1312,77],{"class":69},[55,1314,1315],{"class":57,"line":80},[55,1316,249],{"emptyLinePlaceholder":248},[55,1318,1319,1321,1324,1327,1329,1331,1333],{"class":57,"line":102},[55,1320,488],{"class":487},[55,1322,1323],{"class":61}," answer ",[55,1325,1326],{"class":65},"==",[55,1328,70],{"class":69},[55,1330,506],{"class":73},[55,1332,228],{"class":69},[55,1334,511],{"class":91},[55,1336,1337,1339,1341,1343,1346,1348],{"class":57,"line":266},[55,1338,516],{"class":105},[55,1340,109],{"class":91},[55,1342,228],{"class":69},[55,1344,1345],{"class":73},"Match",[55,1347,228],{"class":69},[55,1349,342],{"class":91},[55,1351,1352,1354],{"class":57,"line":332},[55,1353,610],{"class":487},[55,1355,511],{"class":91},[55,1357,1358,1360,1362,1364,1367,1369],{"class":57,"line":345},[55,1359,516],{"class":105},[55,1361,109],{"class":91},[55,1363,228],{"class":69},[55,1365,1366],{"class":73},"No match",[55,1368,228],{"class":69},[55,1370,342],{"class":91},[20,1372,1373,1374,1377,1378,1381,1382,92],{},"Because ",[15,1375,1376],{},"\"Yes\""," and ",[15,1379,1380],{},"\"yes\""," are different strings, this prints ",[15,1383,1366],{},[20,1385,1386],{},"Better:",[46,1388,1390],{"className":48,"code":1389,"language":50,"meta":51,"style":51},"answer = \"Yes\"\n\nif answer.lower() == \"yes\":\n    print(\"Match\")\n",[15,1391,1392,1404,1408,1430],{"__ignoreMap":51},[55,1393,1394,1396,1398,1400,1402],{"class":57,"line":58},[55,1395,469],{"class":61},[55,1397,66],{"class":65},[55,1399,70],{"class":69},[55,1401,1310],{"class":73},[55,1403,77],{"class":69},[55,1405,1406],{"class":57,"line":80},[55,1407,249],{"emptyLinePlaceholder":248},[55,1409,1410,1412,1414,1416,1418,1420,1422,1424,1426,1428],{"class":57,"line":102},[55,1411,488],{"class":487},[55,1413,491],{"class":61},[55,1415,92],{"class":91},[55,1417,96],{"class":95},[55,1419,498],{"class":91},[55,1421,501],{"class":65},[55,1423,70],{"class":69},[55,1425,506],{"class":73},[55,1427,228],{"class":69},[55,1429,511],{"class":91},[55,1431,1432,1434,1436,1438,1440,1442],{"class":57,"line":266},[55,1433,516],{"class":105},[55,1435,109],{"class":91},[55,1437,228],{"class":69},[55,1439,1345],{"class":73},[55,1441,228],{"class":69},[55,1443,342],{"class":91},[1003,1445,1447,1448,1451],{"id":1446},"when-casefold-may-be-better","When ",[15,1449,1450],{},"casefold()"," may be better",[20,1453,1454,1455,1457],{},"For most beginner examples, ",[15,1456,17],{}," is enough.",[20,1459,1460,1461,1463,1464,92],{},"But for advanced Unicode case-insensitive matching, ",[15,1462,1450],{}," can be stronger than ",[15,1465,17],{},[20,1467,1468,1469,1471],{},"For everyday beginner tasks like input checking and simple comparisons, ",[15,1470,17],{}," is usually the right choice.",[131,1473,1475,1477,1478],{"id":1474},"lower-vs-upper",[15,1476,17],{}," vs ",[15,1479,1480],{},"upper()",[20,1482,1483,1377,1485,1487],{},[15,1484,17],{},[15,1486,1480],{}," are very similar.",[30,1489,1490,1495,1500,1503],{},[33,1491,1492,1494],{},[15,1493,17],{}," changes letters to lowercase",[33,1496,1497,1499],{},[15,1498,1480],{}," changes letters to uppercase",[33,1501,1502],{},"Both return new strings",[33,1504,1505],{},"Both leave the original string unchanged unless you reassign the result",[20,1507,214],{},[46,1509,1511],{"className":48,"code":1510,"language":50,"meta":51,"style":51},"text = \"Hello World\"\n\nprint(text.lower())  # hello world\nprint(text.upper())  # HELLO WORLD\n",[15,1512,1513,1526,1530,1546],{"__ignoreMap":51},[55,1514,1515,1517,1519,1521,1524],{"class":57,"line":58},[55,1516,62],{"class":61},[55,1518,66],{"class":65},[55,1520,70],{"class":69},[55,1522,1523],{"class":73},"Hello World",[55,1525,77],{"class":69},[55,1527,1528],{"class":57,"line":80},[55,1529,249],{"emptyLinePlaceholder":248},[55,1531,1532,1534,1536,1538,1540,1542,1544],{"class":57,"line":102},[55,1533,106],{"class":105},[55,1535,109],{"class":91},[55,1537,352],{"class":95},[55,1539,92],{"class":91},[55,1541,96],{"class":95},[55,1543,240],{"class":91},[55,1545,119],{"class":118},[55,1547,1548,1550,1552,1554,1556,1559,1561],{"class":57,"line":266},[55,1549,106],{"class":105},[55,1551,109],{"class":91},[55,1553,352],{"class":95},[55,1555,92],{"class":91},[55,1557,1558],{"class":95},"upper",[55,1560,240],{"class":91},[55,1562,1563],{"class":118},"  # HELLO WORLD\n",[20,1565,1566,1567,92],{},"If you want the opposite conversion, see the ",[166,1568,1570,1571,1573],{"href":1569},"\u002Freference\u002Fpython-string-upper-method\u002F","Python string ",[15,1572,1480],{}," method",[131,1575,1577],{"id":1576},"faq","FAQ",[1003,1579,1581,1582,1584],{"id":1580},"does-lower-change-the-original-string","Does ",[15,1583,17],{}," change the original string?",[20,1586,1587],{},"No. It returns a new lowercase string. Reassign it if needed.",[1003,1589,1581,1591,1593],{"id":1590},"does-lower-take-any-arguments",[15,1592,17],{}," take any arguments?",[20,1595,1596,1597,92],{},"No. The method is called as ",[15,1598,1599],{},"string.lower()",[1003,1601,1603,1604,1606],{"id":1602},"what-does-lower-return","What does ",[15,1605,17],{}," return?",[20,1608,1609],{},"It returns a new string with lowercase letters.",[1003,1611,1613,1614,1616],{"id":1612},"can-i-use-lower-on-user-input","Can I use ",[15,1615,17],{}," on user input?",[20,1618,1619,1620,1622],{},"Yes. It is commonly used with ",[15,1621,537],{}," to compare answers without case problems.",[1003,1624,1626,1627,1377,1629,1631],{"id":1625},"what-is-the-difference-between-lower-and-casefold","What is the difference between ",[15,1628,17],{},[15,1630,1450],{},"?",[20,1633,1634,1636,1637,1639],{},[15,1635,17],{}," is simpler and common for beginners. ",[15,1638,1450],{}," is stronger for some Unicode case-insensitive comparisons.",[131,1641,1643],{"id":1642},"see-also","See also",[30,1645,1646,1650,1656,1662,1670,1676,1682,1690],{},[33,1647,1648],{},[166,1649,174],{"href":173},[33,1651,1652],{},[166,1653,1570,1654,1573],{"href":1569},[15,1655,1480],{},[33,1657,1658],{},[166,1659,1570,1660,1573],{"href":818},[15,1661,821],{},[33,1663,1664],{},[166,1665,1570,1667,1573],{"href":1666},"\u002Freference\u002Fpython-string-replace-method\u002F",[15,1668,1669],{},"replace()",[33,1671,1672],{},[166,1673,1675],{"href":1674},"\u002Fhow-to\u002Fhow-to-check-if-a-string-contains-a-substring-in-python\u002F","How to check if a string contains a substring in Python",[33,1677,1678],{},[166,1679,1681],{"href":1680},"\u002Fhow-to\u002Fhow-to-format-strings-in-python\u002F","How to format strings in Python",[33,1683,1684],{},[166,1685,1686,1687,1689],{"href":533},"Python ",[15,1688,537],{}," function explained",[33,1691,1692],{},[166,1693,1694],{"href":168},"What is a string in Python?",[1696,1697,1698],"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 .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 .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}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 .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}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 .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":51,"searchDepth":80,"depth":80,"links":1700},[1701,1703,1704,1705,1706,1707,1708,1717,1719,1731],{"id":133,"depth":80,"text":1702},"What lower() does",{"id":177,"depth":80,"text":178},{"id":285,"depth":80,"text":286},{"id":445,"depth":80,"text":446},{"id":630,"depth":80,"text":631},{"id":882,"depth":80,"text":883},{"id":1000,"depth":80,"text":1001,"children":1709},[1710,1711,1712,1714,1715],{"id":1005,"depth":102,"text":1006},{"id":1090,"depth":102,"text":1091},{"id":1184,"depth":102,"text":1713},"Using lower() on a non-string value",{"id":1290,"depth":102,"text":1291},{"id":1446,"depth":102,"text":1716},"When casefold() may be better",{"id":1474,"depth":80,"text":1718},"lower() vs upper()",{"id":1576,"depth":80,"text":1577,"children":1720},[1721,1723,1725,1727,1729],{"id":1580,"depth":102,"text":1722},"Does lower() change the original string?",{"id":1590,"depth":102,"text":1724},"Does lower() take any arguments?",{"id":1602,"depth":102,"text":1726},"What does lower() return?",{"id":1612,"depth":102,"text":1728},"Can I use lower() on user input?",{"id":1625,"depth":102,"text":1730},"What is the difference between lower() and casefold()?",{"id":1642,"depth":80,"text":1643},"Master python string lower method in our comprehensive Python beginner guide.","md",{},"\u002Freference\u002Fpython-string-lower-method",{"title":5,"description":1732},"reference\u002Fpython-string-lower-method","Aspap5dswZ0jaW6T8G5ZAbmL8ux0eq3khybJYFtYHM8",1777585500245]