[{"data":1,"prerenderedAt":1360},["ShallowReactive",2],{"doc-\u002Freference\u002Fpython-string-upper-method":3},{"id":4,"title":5,"body":6,"description":1353,"extension":1354,"meta":1355,"navigation":311,"path":1356,"seo":1357,"stem":1358,"__hash__":1359},"content\u002Freference\u002Fpython-string-upper-method.md","Python String upper() Method",{"type":7,"value":8,"toc":1323},"minimark",[9,19,26,32,37,115,125,132,150,163,167,170,186,189,200,203,237,240,265,269,272,336,339,355,358,372,378,385,388,430,432,441,450,453,499,501,510,513,517,522,536,539,572,574,597,600,606,611,614,625,628,696,698,707,719,723,728,735,738,775,777,786,789,830,832,841,848,853,855,885,895,898,932,934,943,950,959,991,993,1006,1023,1027,1033,1068,1070,1140,1142,1152,1156,1163,1166,1172,1177,1181,1187,1194,1197,1199,1260,1262,1272,1276,1319],[10,11,13,14,18],"h1",{"id":12},"python-string-upper-method","Python String ",[15,16,17],"code",{},"upper()"," Method",[20,21,22,23,25],"p",{},"The Python string ",[15,24,17],{}," method returns a new string with lowercase letters changed to uppercase.",[20,27,28,29,31],{},"This page explains what ",[15,30,17],{}," does, how to use it, what it returns, and a few common beginner mistakes. It stays focused on the method itself.",[33,34,36],"h2",{"id":35},"quick-example","Quick example",[38,39,44],"pre",{"className":40,"code":41,"language":42,"meta":43,"style":43},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","text = \"Hello World\"\nresult = text.upper()\nprint(result)\n# HELLO WORLD\n","python","",[15,45,46,70,92,108],{"__ignoreMap":43},[47,48,51,55,59,63,67],"span",{"class":49,"line":50},"line",1,[47,52,54],{"class":53},"su5hD","text ",[47,56,58],{"class":57},"smGrS","=",[47,60,62],{"class":61},"sjJ54"," \"",[47,64,66],{"class":65},"s_sjI","Hello World",[47,68,69],{"class":61},"\"\n",[47,71,73,76,78,81,85,89],{"class":49,"line":72},2,[47,74,75],{"class":53},"result ",[47,77,58],{"class":57},[47,79,80],{"class":53}," text",[47,82,84],{"class":83},"sP7_E",".",[47,86,88],{"class":87},"slqww","upper",[47,90,91],{"class":83},"()\n",[47,93,95,99,102,105],{"class":49,"line":94},3,[47,96,98],{"class":97},"sptTA","print",[47,100,101],{"class":83},"(",[47,103,104],{"class":87},"result",[47,106,107],{"class":83},")\n",[47,109,111],{"class":49,"line":110},4,[47,112,114],{"class":113},"sutJx","# HELLO WORLD\n",[20,116,117,119,120,124],{},[15,118,17],{}," returns a new string with letters changed to uppercase. It does ",[121,122,123],"strong",{},"not"," change the original string in place.",[33,126,128,129,131],{"id":127},"what-upper-does","What ",[15,130,17],{}," does",[133,134,135,141,144,147],"ul",{},[136,137,138,140],"li",{},[15,139,17],{}," returns a copy of a string with lowercase letters converted to uppercase",[136,142,143],{},"It works on string values only",[136,145,146],{},"It returns a new string",[136,148,149],{},"The original string stays unchanged",[20,151,152,153,158,159,84],{},"If you are new to strings, see ",[154,155,157],"a",{"href":156},"\u002Fglossary\u002Fwhat-is-a-string-in-python\u002F","what a string is in Python"," or ",[154,160,162],{"href":161},"\u002Flearn\u002Fpython-strings-explained-basics-and-examples\u002F","Python strings explained: basics and examples",[33,164,166],{"id":165},"basic-syntax","Basic syntax",[20,168,169],{},"The syntax is:",[38,171,173],{"className":40,"code":172,"language":42,"meta":43,"style":43},"string.upper()\n",[15,174,175],{"__ignoreMap":43},[47,176,177,180,182,184],{"class":49,"line":50},[47,178,179],{"class":53},"string",[47,181,84],{"class":83},[47,183,88],{"class":87},[47,185,91],{"class":83},[20,187,188],{},"Important points:",[133,190,191,194,197],{},[136,192,193],{},"It takes no arguments",[136,195,196],{},"You call it on a string variable or string literal",[136,198,199],{},"It returns the uppercase version of the string",[20,201,202],{},"Example with a variable:",[38,204,206],{"className":40,"code":205,"language":42,"meta":43,"style":43},"name = \"python\"\nprint(name.upper())\n",[15,207,208,221],{"__ignoreMap":43},[47,209,210,213,215,217,219],{"class":49,"line":50},[47,211,212],{"class":53},"name ",[47,214,58],{"class":57},[47,216,62],{"class":61},[47,218,42],{"class":65},[47,220,69],{"class":61},[47,222,223,225,227,230,232,234],{"class":49,"line":72},[47,224,98],{"class":97},[47,226,101],{"class":83},[47,228,229],{"class":87},"name",[47,231,84],{"class":83},[47,233,88],{"class":87},[47,235,236],{"class":83},"())\n",[20,238,239],{},"Example with a string literal:",[38,241,243],{"className":40,"code":242,"language":42,"meta":43,"style":43},"print(\"hello\".upper())\n",[15,244,245],{"__ignoreMap":43},[47,246,247,249,251,254,257,259,261,263],{"class":49,"line":50},[47,248,98],{"class":97},[47,250,101],{"class":83},[47,252,253],{"class":61},"\"",[47,255,256],{"class":65},"hello",[47,258,253],{"class":61},[47,260,84],{"class":83},[47,262,88],{"class":87},[47,264,236],{"class":83},[33,266,268],{"id":267},"simple-example","Simple example",[20,270,271],{},"Here is a basic example that converts a lowercase word to uppercase and stores the result in a new variable:",[38,273,275],{"className":40,"code":274,"language":42,"meta":43,"style":43},"word = \"banana\"\nuppercase_word = word.upper()\n\nprint(word)\nprint(uppercase_word)\n",[15,276,277,291,307,313,324],{"__ignoreMap":43},[47,278,279,282,284,286,289],{"class":49,"line":50},[47,280,281],{"class":53},"word ",[47,283,58],{"class":57},[47,285,62],{"class":61},[47,287,288],{"class":65},"banana",[47,290,69],{"class":61},[47,292,293,296,298,301,303,305],{"class":49,"line":72},[47,294,295],{"class":53},"uppercase_word ",[47,297,58],{"class":57},[47,299,300],{"class":53}," word",[47,302,84],{"class":83},[47,304,88],{"class":87},[47,306,91],{"class":83},[47,308,309],{"class":49,"line":94},[47,310,312],{"emptyLinePlaceholder":311},true,"\n",[47,314,315,317,319,322],{"class":49,"line":110},[47,316,98],{"class":97},[47,318,101],{"class":83},[47,320,321],{"class":87},"word",[47,323,107],{"class":83},[47,325,327,329,331,334],{"class":49,"line":326},5,[47,328,98],{"class":97},[47,330,101],{"class":83},[47,332,333],{"class":87},"uppercase_word",[47,335,107],{"class":83},[20,337,338],{},"Output:",[38,340,342],{"className":40,"code":341,"language":42,"meta":43,"style":43},"banana\nBANANA\n",[15,343,344,349],{"__ignoreMap":43},[47,345,346],{"class":49,"line":50},[47,347,348],{"class":53},"banana\n",[47,350,351],{"class":49,"line":72},[47,352,354],{"class":353},"s_hVV","BANANA\n",[20,356,357],{},"What this shows:",[133,359,360,365],{},[136,361,362,364],{},[15,363,321],{}," keeps its original value",[136,366,367,369,370],{},[15,368,333],{}," stores the returned value from ",[15,371,17],{},[33,373,375,377],{"id":374},"upper-does-not-change-the-original-string",[15,376,17],{}," does not change the original string",[20,379,380,381,384],{},"Strings are ",[121,382,383],{},"immutable"," in Python. That means you cannot change the characters inside a string directly.",[20,386,387],{},"So this method:",[38,389,391],{"className":40,"code":390,"language":42,"meta":43,"style":43},"name = \"alice\"\nname.upper()\n\nprint(name)\n",[15,392,393,406,416,420],{"__ignoreMap":43},[47,394,395,397,399,401,404],{"class":49,"line":50},[47,396,212],{"class":53},[47,398,58],{"class":57},[47,400,62],{"class":61},[47,402,403],{"class":65},"alice",[47,405,69],{"class":61},[47,407,408,410,412,414],{"class":49,"line":72},[47,409,229],{"class":53},[47,411,84],{"class":83},[47,413,88],{"class":87},[47,415,91],{"class":83},[47,417,418],{"class":49,"line":94},[47,419,312],{"emptyLinePlaceholder":311},[47,421,422,424,426,428],{"class":49,"line":110},[47,423,98],{"class":97},[47,425,101],{"class":83},[47,427,229],{"class":87},[47,429,107],{"class":83},[20,431,338],{},[38,433,435],{"className":40,"code":434,"language":42,"meta":43,"style":43},"alice\n",[15,436,437],{"__ignoreMap":43},[47,438,439],{"class":49,"line":50},[47,440,434],{"class":53},[20,442,443,444,446,447,449],{},"Even though ",[15,445,17],{}," was called, ",[15,448,229],{}," did not change because the result was not saved.",[20,451,452],{},"If you want to keep the uppercase version, assign it back to the variable:",[38,454,456],{"className":40,"code":455,"language":42,"meta":43,"style":43},"name = \"alice\"\nname = name.upper()\n\nprint(name)\n",[15,457,458,470,485,489],{"__ignoreMap":43},[47,459,460,462,464,466,468],{"class":49,"line":50},[47,461,212],{"class":53},[47,463,58],{"class":57},[47,465,62],{"class":61},[47,467,403],{"class":65},[47,469,69],{"class":61},[47,471,472,474,476,479,481,483],{"class":49,"line":72},[47,473,212],{"class":53},[47,475,58],{"class":57},[47,477,478],{"class":53}," name",[47,480,84],{"class":83},[47,482,88],{"class":87},[47,484,91],{"class":83},[47,486,487],{"class":49,"line":94},[47,488,312],{"emptyLinePlaceholder":311},[47,490,491,493,495,497],{"class":49,"line":110},[47,492,98],{"class":97},[47,494,101],{"class":83},[47,496,229],{"class":87},[47,498,107],{"class":83},[20,500,338],{},[38,502,504],{"className":40,"code":503,"language":42,"meta":43,"style":43},"ALICE\n",[15,505,506],{"__ignoreMap":43},[47,507,508],{"class":49,"line":50},[47,509,503],{"class":353},[20,511,512],{},"This is one of the most common beginner mistakes with string methods.",[33,514,516],{"id":515},"what-happens-to-numbers-spaces-and-symbols","What happens to numbers, spaces, and symbols",[20,518,519,521],{},[15,520,17],{}," only changes letters that have uppercase forms.",[133,523,524,527,530,533],{},[136,525,526],{},"Numbers stay the same",[136,528,529],{},"Spaces stay the same",[136,531,532],{},"Punctuation stays the same",[136,534,535],{},"Only letters are changed",[20,537,538],{},"Example:",[38,540,542],{"className":40,"code":541,"language":42,"meta":43,"style":43},"text = \"Room 7, table #3!\"\nprint(text.upper())\n",[15,543,544,557],{"__ignoreMap":43},[47,545,546,548,550,552,555],{"class":49,"line":50},[47,547,54],{"class":53},[47,549,58],{"class":57},[47,551,62],{"class":61},[47,553,554],{"class":65},"Room 7, table #3!",[47,556,69],{"class":61},[47,558,559,561,563,566,568,570],{"class":49,"line":72},[47,560,98],{"class":97},[47,562,101],{"class":83},[47,564,565],{"class":87},"text",[47,567,84],{"class":83},[47,569,88],{"class":87},[47,571,236],{"class":83},[20,573,338],{},[38,575,577],{"className":40,"code":576,"language":42,"meta":43,"style":43},"ROOM 7, TABLE #3!\n",[15,578,579],{"__ignoreMap":43},[47,580,581,584,588,591,594],{"class":49,"line":50},[47,582,583],{"class":353},"ROOM",[47,585,587],{"class":586},"srdBf"," 7",[47,589,590],{"class":83},",",[47,592,593],{"class":353}," TABLE",[47,595,596],{"class":113}," #3!\n",[20,598,599],{},"The letters changed to uppercase, but the number, space, comma, and symbol stayed the same.",[33,601,603,604],{"id":602},"when-to-use-upper","When to use ",[15,605,17],{},[20,607,608,610],{},[15,609,17],{}," is useful when you want to standardize text.",[20,612,613],{},"Common uses:",[133,615,616,619,622],{},[136,617,618],{},"Standardize user input for comparisons",[136,620,621],{},"Format labels or headings",[136,623,624],{},"Make text easier to compare in simple cases",[20,626,627],{},"Example: simple comparison",[38,629,631],{"className":40,"code":630,"language":42,"meta":43,"style":43},"answer = \"yes\"\n\nif answer.upper() == \"YES\":\n    print(\"Matched\")\n",[15,632,633,647,651,680],{"__ignoreMap":43},[47,634,635,638,640,642,645],{"class":49,"line":50},[47,636,637],{"class":53},"answer ",[47,639,58],{"class":57},[47,641,62],{"class":61},[47,643,644],{"class":65},"yes",[47,646,69],{"class":61},[47,648,649],{"class":49,"line":72},[47,650,312],{"emptyLinePlaceholder":311},[47,652,653,657,660,662,664,667,670,672,675,677],{"class":49,"line":94},[47,654,656],{"class":655},"sVHd0","if",[47,658,659],{"class":53}," answer",[47,661,84],{"class":83},[47,663,88],{"class":87},[47,665,666],{"class":83},"()",[47,668,669],{"class":57}," ==",[47,671,62],{"class":61},[47,673,674],{"class":65},"YES",[47,676,253],{"class":61},[47,678,679],{"class":83},":\n",[47,681,682,685,687,689,692,694],{"class":49,"line":110},[47,683,684],{"class":97},"    print",[47,686,101],{"class":83},[47,688,253],{"class":61},[47,690,691],{"class":65},"Matched",[47,693,253],{"class":61},[47,695,107],{"class":83},[20,697,338],{},[38,699,701],{"className":40,"code":700,"language":42,"meta":43,"style":43},"Matched\n",[15,702,703],{"__ignoreMap":43},[47,704,705],{"class":49,"line":50},[47,706,700],{"class":53},[20,708,709,710,712,713,716,717,84],{},"This can help when users type different letter cases, such as ",[15,711,644],{},", ",[15,714,715],{},"Yes",", or ",[15,718,674],{},[33,720,722],{"id":721},"common-mistakes","Common mistakes",[724,725,727],"h3",{"id":726},"forgetting-to-save-the-returned-value","Forgetting to save the returned value",[20,729,730,731,734],{},"A very common mistake is expecting ",[15,732,733],{},"text.upper()"," to change the original variable automatically.",[20,736,737],{},"Wrong:",[38,739,741],{"className":40,"code":740,"language":42,"meta":43,"style":43},"text = \"hello\"\ntext.upper()\nprint(text)\n",[15,742,743,755,765],{"__ignoreMap":43},[47,744,745,747,749,751,753],{"class":49,"line":50},[47,746,54],{"class":53},[47,748,58],{"class":57},[47,750,62],{"class":61},[47,752,256],{"class":65},[47,754,69],{"class":61},[47,756,757,759,761,763],{"class":49,"line":72},[47,758,565],{"class":53},[47,760,84],{"class":83},[47,762,88],{"class":87},[47,764,91],{"class":83},[47,766,767,769,771,773],{"class":49,"line":94},[47,768,98],{"class":97},[47,770,101],{"class":83},[47,772,565],{"class":87},[47,774,107],{"class":83},[20,776,338],{},[38,778,780],{"className":40,"code":779,"language":42,"meta":43,"style":43},"hello\n",[15,781,782],{"__ignoreMap":43},[47,783,784],{"class":49,"line":50},[47,785,779],{"class":53},[20,787,788],{},"Correct:",[38,790,792],{"className":40,"code":791,"language":42,"meta":43,"style":43},"text = \"hello\"\ntext = text.upper()\nprint(text)\n",[15,793,794,806,820],{"__ignoreMap":43},[47,795,796,798,800,802,804],{"class":49,"line":50},[47,797,54],{"class":53},[47,799,58],{"class":57},[47,801,62],{"class":61},[47,803,256],{"class":65},[47,805,69],{"class":61},[47,807,808,810,812,814,816,818],{"class":49,"line":72},[47,809,54],{"class":53},[47,811,58],{"class":57},[47,813,80],{"class":53},[47,815,84],{"class":83},[47,817,88],{"class":87},[47,819,91],{"class":83},[47,821,822,824,826,828],{"class":49,"line":94},[47,823,98],{"class":97},[47,825,101],{"class":83},[47,827,565],{"class":87},[47,829,107],{"class":83},[20,831,338],{},[38,833,835],{"className":40,"code":834,"language":42,"meta":43,"style":43},"HELLO\n",[15,836,837],{"__ignoreMap":43},[47,838,839],{"class":49,"line":50},[47,840,834],{"class":353},[724,842,844,845,847],{"id":843},"trying-to-call-upper-on-a-non-string-value","Trying to call ",[15,846,17],{}," on a non-string value",[20,849,850,852],{},[15,851,17],{}," is a string method. If the value is not a string, it will fail.",[20,854,538],{},[38,856,858],{"className":40,"code":857,"language":42,"meta":43,"style":43},"number = 123\nprint(number.upper())\n",[15,859,860,870],{"__ignoreMap":43},[47,861,862,865,867],{"class":49,"line":50},[47,863,864],{"class":53},"number ",[47,866,58],{"class":57},[47,868,869],{"class":586}," 123\n",[47,871,872,874,876,879,881,883],{"class":49,"line":72},[47,873,98],{"class":97},[47,875,101],{"class":83},[47,877,878],{"class":87},"number",[47,880,84],{"class":83},[47,882,88],{"class":87},[47,884,236],{"class":83},[20,886,887,888,891,892,894],{},"This causes an error because ",[15,889,890],{},"int"," objects do not have an ",[15,893,17],{}," method.",[20,896,897],{},"If needed, convert the value to a string first:",[38,899,901],{"className":40,"code":900,"language":42,"meta":43,"style":43},"number = 123\nprint(str(number).upper())\n",[15,902,903,911],{"__ignoreMap":43},[47,904,905,907,909],{"class":49,"line":50},[47,906,864],{"class":53},[47,908,58],{"class":57},[47,910,869],{"class":586},[47,912,913,915,917,921,923,925,928,930],{"class":49,"line":72},[47,914,98],{"class":97},[47,916,101],{"class":83},[47,918,920],{"class":919},"sZMiF","str",[47,922,101],{"class":83},[47,924,878],{"class":87},[47,926,927],{"class":83},").",[47,929,88],{"class":87},[47,931,236],{"class":83},[20,933,338],{},[38,935,937],{"className":40,"code":936,"language":42,"meta":43,"style":43},"123\n",[15,938,939],{"__ignoreMap":43},[47,940,941],{"class":49,"line":50},[47,942,936],{"class":586},[724,944,946,947,949],{"id":945},"confusing-upper-with-title-case","Confusing ",[15,948,17],{}," with title case",[20,951,952,954,955,958],{},[15,953,17],{}," makes ",[121,956,957],{},"all letters uppercase",". It does not make every word start with a capital letter.",[38,960,962],{"className":40,"code":961,"language":42,"meta":43,"style":43},"text = \"hello world\"\nprint(text.upper())\n",[15,963,964,977],{"__ignoreMap":43},[47,965,966,968,970,972,975],{"class":49,"line":50},[47,967,54],{"class":53},[47,969,58],{"class":57},[47,971,62],{"class":61},[47,973,974],{"class":65},"hello world",[47,976,69],{"class":61},[47,978,979,981,983,985,987,989],{"class":49,"line":72},[47,980,98],{"class":97},[47,982,101],{"class":83},[47,984,565],{"class":87},[47,986,84],{"class":83},[47,988,88],{"class":87},[47,990,236],{"class":83},[20,992,338],{},[38,994,996],{"className":40,"code":995,"language":42,"meta":43,"style":43},"HELLO WORLD\n",[15,997,998],{"__ignoreMap":43},[47,999,1000,1003],{"class":49,"line":50},[47,1001,1002],{"class":353},"HELLO",[47,1004,1005],{"class":353}," WORLD\n",[20,1007,1008,1009,1015,1016,1022],{},"If your goal is different, another method may fit better. For example, ",[154,1010,1012],{"href":1011},"\u002Freference\u002Fpython-string-lower-method\u002F",[15,1013,1014],{},"lower()"," makes text lowercase, and ",[154,1017,1019],{"href":1018},"\u002Freference\u002Fpython-string-replace-method\u002F",[15,1020,1021],{},"replace()"," changes parts of a string.",[33,1024,1026],{"id":1025},"related-string-methods","Related string methods",[20,1028,1029,1030,1032],{},"These string methods are often used with ",[15,1031,17],{},":",[133,1034,1035,1042,1051,1058],{},[136,1036,1037,1041],{},[154,1038,1039],{"href":1011},[15,1040,1014],{}," for lowercase text",[136,1043,1044,1050],{},[154,1045,1047],{"href":1046},"\u002Freference\u002Fpython-string-strip-method\u002F",[15,1048,1049],{},"strip()"," for removing leading and trailing whitespace",[136,1052,1053,1057],{},[154,1054,1055],{"href":1018},[15,1056,1021],{}," for changing parts of a string",[136,1059,1060,1063,1064,1067],{},[15,1061,1062],{},"startswith()"," and ",[15,1065,1066],{},"endswith()"," for checks",[20,1069,538],{},[38,1071,1073],{"className":40,"code":1072,"language":42,"meta":43,"style":43},"text = \"  hello world  \"\n\ncleaned = text.strip()\nloud = cleaned.upper()\n\nprint(loud)\n",[15,1074,1075,1088,1092,1108,1124,1128],{"__ignoreMap":43},[47,1076,1077,1079,1081,1083,1086],{"class":49,"line":50},[47,1078,54],{"class":53},[47,1080,58],{"class":57},[47,1082,62],{"class":61},[47,1084,1085],{"class":65},"  hello world  ",[47,1087,69],{"class":61},[47,1089,1090],{"class":49,"line":72},[47,1091,312],{"emptyLinePlaceholder":311},[47,1093,1094,1097,1099,1101,1103,1106],{"class":49,"line":94},[47,1095,1096],{"class":53},"cleaned ",[47,1098,58],{"class":57},[47,1100,80],{"class":53},[47,1102,84],{"class":83},[47,1104,1105],{"class":87},"strip",[47,1107,91],{"class":83},[47,1109,1110,1113,1115,1118,1120,1122],{"class":49,"line":110},[47,1111,1112],{"class":53},"loud ",[47,1114,58],{"class":57},[47,1116,1117],{"class":53}," cleaned",[47,1119,84],{"class":83},[47,1121,88],{"class":87},[47,1123,91],{"class":83},[47,1125,1126],{"class":49,"line":326},[47,1127,312],{"emptyLinePlaceholder":311},[47,1129,1131,1133,1135,1138],{"class":49,"line":1130},6,[47,1132,98],{"class":97},[47,1134,101],{"class":83},[47,1136,1137],{"class":87},"loud",[47,1139,107],{"class":83},[20,1141,338],{},[38,1143,1144],{"className":40,"code":995,"language":42,"meta":43,"style":43},[15,1145,1146],{"__ignoreMap":43},[47,1147,1148,1150],{"class":49,"line":50},[47,1149,1002],{"class":353},[47,1151,1005],{"class":353},[33,1153,1155],{"id":1154},"faq","FAQ",[724,1157,1159,1160,1162],{"id":1158},"does-upper-change-the-original-string","Does ",[15,1161,17],{}," change the original string?",[20,1164,1165],{},"No. It returns a new uppercase string. Save the result if you want to keep it.",[724,1167,1159,1169,1171],{"id":1168},"does-upper-take-any-arguments",[15,1170,17],{}," take any arguments?",[20,1173,1174,1175,84],{},"No. The method is called with empty parentheses: ",[15,1176,733],{},[724,1178,1180],{"id":1179},"what-happens-to-numbers-and-symbols","What happens to numbers and symbols?",[20,1182,1183,1184,1186],{},"They stay the same. ",[15,1185,17],{}," only changes letters that can be converted to uppercase.",[724,1188,1190,1191,1193],{"id":1189},"can-i-use-upper-for-case-insensitive-comparison","Can I use ",[15,1192,17],{}," for case-insensitive comparison?",[20,1195,1196],{},"Yes, for simple cases. Convert both strings before comparing them.",[20,1198,538],{},[38,1200,1202],{"className":40,"code":1201,"language":42,"meta":43,"style":43},"a = \"python\"\nb = \"PYTHON\"\n\nprint(a.upper() == b.upper())\n",[15,1203,1204,1217,1231,1235],{"__ignoreMap":43},[47,1205,1206,1209,1211,1213,1215],{"class":49,"line":50},[47,1207,1208],{"class":53},"a ",[47,1210,58],{"class":57},[47,1212,62],{"class":61},[47,1214,42],{"class":65},[47,1216,69],{"class":61},[47,1218,1219,1222,1224,1226,1229],{"class":49,"line":72},[47,1220,1221],{"class":53},"b ",[47,1223,58],{"class":57},[47,1225,62],{"class":61},[47,1227,1228],{"class":65},"PYTHON",[47,1230,69],{"class":61},[47,1232,1233],{"class":49,"line":94},[47,1234,312],{"emptyLinePlaceholder":311},[47,1236,1237,1239,1241,1243,1245,1247,1249,1251,1254,1256,1258],{"class":49,"line":110},[47,1238,98],{"class":97},[47,1240,101],{"class":83},[47,1242,154],{"class":87},[47,1244,84],{"class":83},[47,1246,88],{"class":87},[47,1248,666],{"class":83},[47,1250,669],{"class":57},[47,1252,1253],{"class":87}," b",[47,1255,84],{"class":83},[47,1257,88],{"class":87},[47,1259,236],{"class":83},[20,1261,338],{},[38,1263,1265],{"className":40,"code":1264,"language":42,"meta":43,"style":43},"True\n",[15,1266,1267],{"__ignoreMap":43},[47,1268,1269],{"class":49,"line":50},[47,1270,1264],{"class":1271},"s39Yj",[33,1273,1275],{"id":1274},"see-also","See also",[133,1277,1278,1282,1290,1296,1302,1308,1314],{},[136,1279,1280],{},[154,1281,162],{"href":161},[136,1283,1284],{},[154,1285,1286,1287,1289],{"href":1011},"Python string ",[15,1288,1014],{}," method",[136,1291,1292],{},[154,1293,1286,1294,1289],{"href":1046},[15,1295,1049],{},[136,1297,1298],{},[154,1299,1286,1300,1289],{"href":1018},[15,1301,1021],{},[136,1303,1304],{},[154,1305,1307],{"href":1306},"\u002Fhow-to\u002Fhow-to-format-strings-in-python\u002F","How to format strings in Python",[136,1309,1310],{},[154,1311,1313],{"href":1312},"\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",[136,1315,1316],{},[154,1317,1318],{"href":156},"What is a string in Python?",[1320,1321,1322],"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 .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--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 .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":43,"searchDepth":72,"depth":72,"links":1324},[1325,1326,1328,1329,1330,1332,1333,1335,1342,1343,1352],{"id":35,"depth":72,"text":36},{"id":127,"depth":72,"text":1327},"What upper() does",{"id":165,"depth":72,"text":166},{"id":267,"depth":72,"text":268},{"id":374,"depth":72,"text":1331},"upper() does not change the original string",{"id":515,"depth":72,"text":516},{"id":602,"depth":72,"text":1334},"When to use upper()",{"id":721,"depth":72,"text":722,"children":1336},[1337,1338,1340],{"id":726,"depth":94,"text":727},{"id":843,"depth":94,"text":1339},"Trying to call upper() on a non-string value",{"id":945,"depth":94,"text":1341},"Confusing upper() with title case",{"id":1025,"depth":72,"text":1026},{"id":1154,"depth":72,"text":1155,"children":1344},[1345,1347,1349,1350],{"id":1158,"depth":94,"text":1346},"Does upper() change the original string?",{"id":1168,"depth":94,"text":1348},"Does upper() take any arguments?",{"id":1179,"depth":94,"text":1180},{"id":1189,"depth":94,"text":1351},"Can I use upper() for case-insensitive comparison?",{"id":1274,"depth":72,"text":1275},"Master python string upper method in our comprehensive Python beginner guide.","md",{},"\u002Freference\u002Fpython-string-upper-method",{"title":5,"description":1353},"reference\u002Fpython-string-upper-method","CsxUKCdYvLDpit9Dq111nYxjaDPu17cNNaa2kyQ-PpY",1777585506150]