{"id":12213,"date":"2020-06-16T14:29:55","date_gmt":"2020-06-16T21:29:55","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12213"},"modified":"2023-12-01T03:22:15","modified_gmt":"2023-12-01T11:22:15","slug":"python-string-methods","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-string-methods\/","title":{"rendered":"Python String Methods: Step-By-Step Guide"},"content":{"rendered":"\n<p><em>Python has many methods used exclusively for strings. Python string methods include <code>upper()<\/code>, <code>lower()<\/code>, <code>capitalize()<\/code>, <code>title()<\/code>, and more. These string methods are useful for manipulating, editing, and working with strings.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>Strings are one of the core data types used in programming, and they allow computers to work with text. For example, a string may be used to store a user\u2019s name or their email address in a Python program.<\/p>\n\n\n\n<p>Python includes several string methods that can be used to modify and manipulate strings. These functions are built into Python and so are ready for us to use without importing any libraries.<\/p>\n\n\n\n<p>In this tutorial, we are going to break down a few of the most common string methods you are likely to encounter in Python and explore examples of how they may be used.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">String Refresher<\/h2>\n\n\n\n<p>Strings allow you to store text when you\u2019re programming and are declared within single quotes <code>\u2018\u2019<\/code> or double quotes <code>\u201c\u201d<\/code> in Python. While you can use either single quotes or double quotes, when you decide which one to use you should keep it consistent throughout your program. Here\u2019s an example of declaring a string:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\"This is an example string in Python.\"<\/pre><\/div>\n\n\n\n<p>We can print out a string by using the <code>print()<\/code> function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(\"This is an example string!\")<\/pre><\/div>\n\n\n\n<p>Our program returns:  <code>This is an example string!<\/code><\/p>\n\n\n\n<p>When you\u2019re working with a string, you may want to merge it with another string to create a new one. We call this string concatenation in programming. In order to merge two strings, we use the <code>+<\/code> operator. Here\u2019s an example of a <code>print()<\/code> function that will merge two strings together:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(\"Example\" + \"String\")<\/pre><\/div>\n\n\n\n<p>Our program returns: <code>ExampleString<\/code>. Note that when we merge our strings, there are no spaces included. If we want to include a space, we should add a whitespace character within our strings.<\/p>\n\n\n\n<p>Now that we\u2019ve explored the basics of strings, we can start to explore Python string methods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Upper and Lower Case Strings<\/h2>\n\n\n\n<p>Two of the most common string functions in Python are those which allow you to change the cases of your strings to upper or lower case. The functions <code>upper()<\/code> and <code>lower()<\/code> will return a string with all the original letters in the string converted into either upper or lower case.<\/p>\n\n\n\n<p>When you use the <code>upper()<\/code> or <code>lower()<\/code> functions, the returned string will be a new string, and your existing string will remain the same.<\/p>\n\n\n\n<p>Here\u2019s an example of the <code>upper()<\/code> class being used to convert a string to uppercase: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>string_example = \"String Example\"\nprint(string_example.upper())<\/pre><\/div>\n\n\n\n<p>Our program returns:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\"STRING EXAMPLE\".<\/pre><\/div>\n\n\n\n<p>If we wanted our string to appear in lowercase, we could use the <code>lower()<\/code> function like this: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(string_example.lower())<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>\"string example\".<\/pre><\/div>\n\n\n\n<p>In addition, you can use the <code>capitalize()<\/code> method to capitalize the first character of a string, and the <code>title()<\/code> method to capitalize the first letter of every word in a string.<\/p>\n\n\n\n<p>These functions are useful if you want to compare strings and want to keep the cases of those strings consistent. This is important because comparisons in Python are case sensitive. For example, you may want to convert a user\u2019s email address to lower case so that you can compare it with the one you have on file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">String Length<\/h2>\n\n\n\n<p>When you\u2019re working with a string, you may want to find out the length of that string. The <code>len()<\/code> Python string method can be used to return the number of characters in a string.<\/p>\n\n\n\n<p>This function is useful if you want to set minimum or maximum lengths for a form field, for example. If you want a user\u2019s email address to be no more than 50 characters, you could use <code>len()<\/code> to find out the length of the email and present an error if it is more than 50 characters long.<\/p>\n\n\n\n<p>Here\u2019s an example of a program that checks the length of a string: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>string_length = \"What is the length of this string?\"\nprint(len(string_length))<\/pre><\/div>\n\n\n\n<p>Our program returns: 34. In our code, we declared the variable <code>string_length<\/code> which stored the string <code>What is the length of this string?<\/code> Then, on the next line, we used the <code>len(string_length)<\/code> method to find out the length of our string, and passed it through the print() method so that we could see the length in our console.<\/p>\n\n\n\n<p>Remember that the length function will count every character in a string, which includes letters, numbers, and whitespace characters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Boolean String Methods<\/h2>\n\n\n\n<p>There are a number of Python string methods that return a boolean value. These methods are useful if we want to learn more about the characteristics of a string. For example, if we want to check if a string is uppercase, or if it contains only numbers, we could use a boolean string method that will return true if all characters are uppercase.&nbsp;<\/p>\n\n\n\n<p>Here is a list of the Python string methods that return True if their condition is met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>str.isupper()<\/code>: String\u2019s alphabetic characters are all uppercase<\/li>\n\n\n\n<li><code>str.islower()<\/code>: String\u2019s alphabetic characters are all lower case<\/li>\n\n\n\n<li><code>str.istitle()<\/code>: String is in title case<\/li>\n\n\n\n<li><code>str.isspace()<\/code>: String only consists of whitespace characters<\/li>\n\n\n\n<li><code>str.isnumeric()<\/code>: String only contains numeric characters<\/li>\n\n\n\n<li><code>str.isalnum()<\/code>: String contains only alphanumeric characters (no symbols)<\/li>\n\n\n\n<li><code>str.isalpha()<\/code>: String contains only alphabetic characters (no numbers or symbols)<\/li>\n<\/ul>\n\n\n\n<p>Let\u2019s explore a few of these boolean string methods. Here\u2019s an example of the <code>isupper()<\/code> function being used to check if a string contains only uppercase characters: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>full_name = \"JOHN APPLESEED\"\nprint(full_name.isupper())<\/pre><\/div>\n\n\n\n<p>Our program returns: True. The <code>full_name<\/code> variable contains a value with text that is entirely in uppercase, and so our <code>isupper()<\/code> function evaluates to True and returns the True value.<\/p>\n\n\n\n<p>Similarly, we can use the <code>istitle()<\/code> function to check if a string is in title case:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>sentence = \"This is a sentence.\"\nprint(sentence.istitle())<\/pre><\/div>\n\n\n\n<p>Our code returns: False. Because our string is not in title case\u2014each character does not begin with a capital letter\u2014our <code>istitle()<\/code> method evaluates to False.<\/p>\n\n\n\n<p>Boolean string methods can be useful when receiving user input that you want to check, or if you have two exact values that you want to compare.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Starts With and Ends With<\/h2>\n\n\n\n<p>Let\u2019s say you have a string and you want to check if it starts or ends with a particular value. For example, you may have a user\u2019s name and want to check if it starts with <code>F<\/code>. We can use the <code>startswith()<\/code> and <code>endswith()<\/code> functions to check our strings.<\/p>\n\n\n\n<p>The <code>startswith()<\/code> method returns True if a string starts with a specific value, and the <code>endswith()<\/code> method returns True if a string ends with a specific value. Otherwise, the string methods return false.<\/p>\n\n\n\n<p>Both methods take three parameters. The first is the value that you are looking for. Optionally, you can specify the starting index within the string where your search should begin with the second parameter, and you can also state the ending index where your search should end with the third.<\/p>\n\n\n\n<p>Here\u2019s an example of the <code>startswith()<\/code> function in action: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>full_name = \"Bill Jefferson\"\nprint(full_name.startswith(\"Bill\"))<\/pre><\/div>\n\n\n\n<p>Our program returns: True.<\/p>\n\n\n\n<p>If we wanted to check if <code>Bill<\/code> appeared in our string starting after the fourth letter in our string\u2014the item with the index value <code>3<\/code>, because indexes start at <code>0<\/code>\u2014we could use the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>full_name = \"Bill Jefferson\"\nprint(full_name.startswith(\"Bill\", 3))<\/pre><\/div>\n\n\n\n<p>Our code returns <code>False<\/code>, because <code>Bill<\/code> does not appear in the string after the index value <code>3<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Split and Join Strings<\/h2>\n\n\n\n<p>In addition, you can use the <code>join()<\/code> and <code>split()<\/code> methods to manipulate strings in Python.<\/p>\n\n\n\n<p>The <code>join()<\/code> method takes all the items in an iterable string and joins them to another string. Here\u2019s an example of the <code>join()<\/code> Python string method in action:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>string = \"String\"\n\"X\".join(string)<\/pre><\/div>\n\n\n\n<p>Our code returns the following: <code>SXtXrXiXnXg<\/code>. What has happened is the <code>join()<\/code> string has gone through each letter in the <code>string<\/code> variable and added an <code>X<\/code> after each letter.<\/p>\n\n\n\n<p>The <code>join()<\/code> method can be useful if you want to join a certain value together with a string. The method is also often used to combine a list of strings together. Here\u2019s an example of <code>join()<\/code> being used to combine a list of strings into one:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(\",\".join([\"Lucy\", \"Emily\", \"David\"])<\/pre><\/div>\n\n\n\n<p>Our code returns the following: <code>Lucy<\/code>,<code>Emily<\/code>,<code>David<\/code>. Now our list of names is in one string, rather than in an array.<\/p>\n\n\n\n<p>We can also use the <code>split()<\/code> string method to split up a string and return a list of strings. Here\u2019s an example of the <code>split()<\/code> method being used to divide a sentence into a list of strings:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>example_sentence = \"This is a sentence.\"\nprint(example_sentence.split())<\/pre><\/div>\n\n\n\n<p>Our code returns the following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[\"This\", \"is\", \"a\", \"sentence.\"]<\/pre><\/div>\n\n\n\n<p>As you can see, our original string has been divided into four items and a new list of those items has been created.<\/p>\n\n\n\n<p>The <code>split()<\/code> method returns a list of strings separated by whitespace characters if no other parameter is specified, but if you want to split a string by another character, you can. Here\u2019s an example of a program that divides a string based on the commas in that string:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>names = \"Lucy,Emily,David\"\nprint(names.split(\",\"))<\/pre><\/div>\n\n\n\n<p>Our code returns: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>[\"Lucy\", \"Emily\", \"David\"]<\/pre><\/div>\n\n\n\n<p>As you can see, our program has separated our strings by the comma values in our initial string and created an array with the new separate values.<\/p>\n\n\n\n<p><strong>View the Repl.it from this tutorial:<\/strong> <\/p>\n\n\n\n<iframe loading=\"lazy\" frameborder=\"0\" width=\"100%\" height=\"400px\" src=\"https:\/\/repl.it\/@careerkarma\/Python-String-Methods?lite=true\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Strings are a useful data type that allow coders to store text values in their programs. In this tutorial, we explored some of the most common built-in Python string methods that you can use to manipulate strings.<\/p>\n\n\n\n<p>We discussed the <code>upper()<\/code> and <code>lower()<\/code> methods and how they can help you work with cases in Python, the <code>len()<\/code> method and how it can help you get the length of a string, and we explored the boolean string methods available in Python.<\/p>\n\n\n\n<p>We also discussed how to use <code>join()<\/code> and <code>split()<\/code>, and how to check if a string starts with or ends with a substring.<\/p>\n\n\n\n<p>It\u2019s worth noting that there are a number of other string methods out there such as <code>ljust()<\/code>, <code>rjust()<\/code>, and <code>zfill()<\/code>, and this article only scratches the surface. Now you\u2019re ready to start working with strings in Python like an expert!<\/p>\n","protected":false},"excerpt":{"rendered":"Python has many methods used exclusively for strings. Python string methods include upper(), lower(), capitalize(), title(), and more. These string methods are useful for manipulating, editing, and working with strings. Strings are one of the core data types used in programming, and they allow computers to work with text. For example, a string may be&hellip;","protected":false},"author":240,"featured_media":12254,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-12213","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python String Methods: Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Python includes a number of built-in functions to work with strings. Learn about the top Python string methods on Career Karma.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python String Methods: Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"Python includes a number of built-in functions to work with strings. Learn about the top Python string methods on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-16T21:29:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:22:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python String Methods: Step-By-Step Guide\",\"datePublished\":\"2020-06-16T21:29:55+00:00\",\"dateModified\":\"2023-12-01T11:22:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\"},\"wordCount\":1545,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\",\"name\":\"Python String Methods: Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg\",\"datePublished\":\"2020-06-16T21:29:55+00:00\",\"dateModified\":\"2023-12-01T11:22:15+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Python includes a number of built-in functions to work with strings. Learn about the top Python string methods on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg\",\"width\":1000,\"height\":668},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-string-methods\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python String Methods: Step-By-Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python String Methods: Step-By-Step Guide | Career Karma","description":"Python includes a number of built-in functions to work with strings. Learn about the top Python string methods on Career Karma.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/python-string-methods\/","og_locale":"en_US","og_type":"article","og_title":"Python String Methods: Step-By-Step Guide","og_description":"Python includes a number of built-in functions to work with strings. Learn about the top Python string methods on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/python-string-methods\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-06-16T21:29:55+00:00","article_modified_time":"2023-12-01T11:22:15+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python String Methods: Step-By-Step Guide","datePublished":"2020-06-16T21:29:55+00:00","dateModified":"2023-12-01T11:22:15+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/"},"wordCount":1545,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-string-methods\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/","url":"https:\/\/careerkarma.com\/blog\/python-string-methods\/","name":"Python String Methods: Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","datePublished":"2020-06-16T21:29:55+00:00","dateModified":"2023-12-01T11:22:15+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Python includes a number of built-in functions to work with strings. Learn about the top Python string methods on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-string-methods\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","width":1000,"height":668},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-string-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python String Methods: Step-By-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=12213"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12213\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12254"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=12213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}