{"id":3590,"date":"2022-12-01T20:15:53","date_gmt":"2022-12-01T20:15:53","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=3590"},"modified":"2022-12-01T20:15:54","modified_gmt":"2022-12-01T20:15:54","slug":"python-string-capitalize","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/python-string-capitalize\/","title":{"rendered":"Python String capitalize() Method With Example"},"content":{"rendered":"<p style=\"text-align: center;\">Python String Capitalize<\/p>\n<p>As we have seen in the above table, the <strong>capitalize<\/strong> method returns the copy of the string, with the first character in uppercase, and the rest of the characters in lowercase. Once we learn to use the method and see the output, we would simply understand what the method has to do. One thing to note here is that the method here does not affect the original string.<\/p>\n<p>When we are using the capitalize method on some string, a new string is created with the new changes, and the original string stays as it was. Let\u2019s get to the example &#8211;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3591 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-capitalize-METHOD.jpg\" alt=\"\" width=\"644\" height=\"95\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-capitalize-METHOD.jpg 644w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-capitalize-METHOD-300x44.jpg 300w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/p>\n<h2 style=\"text-align: center;\">Python String capitalize() Method<\/h2>\n<p>As you can see in the above program, we have used the method on the string1. The way we did it is simple. We just have to write the variable name, which refers to the object on which we are using the method, followed by a dot, and then the method name, and do not forget the brackets there. This is similar to what we call some functions. But here, this function capitalize is being used on some string, so this is a method here, and you would soon get familiar with the way we are calling the methods.<\/p>\n<p>Also, we are printing the output from the capitalize method, as well as the original string. We can simply find that the original string is as it was, and with the capitalization, we got a new string with the effective changes. We are directly printing the string, but you can assign it to some variable as well if you need it later.<\/p>\n<p>If you have a look at the output for the above program, the capitalized string appears somewhat like this \u2013 &#8216;Hello from Gyanipandit&#8217;.<\/p>\n<p>Even all the other characters that were in the uppercase in the string, were simply lowercase, and so we got the output. You can try this method as well, so as to become familiar with it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python String Capitalize As we have seen in the above table, the capitalize method returns the copy of the string, with the first character in uppercase, and the rest of the characters in lowercase. Once we learn to use the method and see the output, we would simply understand what the method has to do. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[26,27],"class_list":{"0":"post-3590","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python-tutorial","7":"tag-python","8":"tag-python-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=3590"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3590\/revisions"}],"predecessor-version":[{"id":4165,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3590\/revisions\/4165"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=3590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=3590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=3590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}