{"id":12885,"date":"2020-07-23T01:24:18","date_gmt":"2020-07-23T08:24:18","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12885"},"modified":"2023-12-01T03:55:56","modified_gmt":"2023-12-01T11:55:56","slug":"python-compare-strings","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/","title":{"rendered":"Python Compare Strings: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>Strings in Python are compared with <\/em><code><em>==<\/em><\/code><em> and <\/em><code><em>!=<\/em><\/code><em> operators. These compare if two Python strings are equivalent or not equivalent, respectively. They return <\/em><code><em>True<\/em><\/code><em> or <\/em><code><em>False<\/em><\/code><em>. <\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Often, when you\u2019re working with strings in Python, you may want to compare them to each other. For example, you may want to compare a user\u2019s email address against the one you have stored in a database when you are asking them to reset their password.<\/p>\n\n\n\n<p>Python includes a number of comparison operators that can be used to compare strings. These operators allow you to check how strings compare to each other, and return a True or False value based on the outcome.<\/p>\n\n\n\n<p>This tutorial will discuss the comparison operators available for comparing strings in Python. We\u2019ll walk through an example of each of these operators to show how they work, and how you can use them in your code. If you\u2019re looking to learn how to compare strings in Python, this article is for you. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python String is and is Not Equal To<\/h2>\n\n\n\n<p>Strings are sequences of characters that can include numbers, letters, symbols, and whitespaces. Strings are an important data type because they allow coders to interact with text-based data in their programs.<\/p>\n\n\n\n<p>When you\u2019re working with a string, you may want to see whether a string is or is not equal to another string. That\u2019s where the <code>==<\/code> and <code>!=<\/code> string comparison operators come in.<\/p>\n\n\n\n<p>The <code>==<\/code> equality operator returns True if two values match; otherwise, the operator returns False. The <code>!=<\/code> operator returns True if two values do not match, and False if two values match.<\/p>\n\n\n\n<p>It\u2019s important to note that string comparisons are <strong>case sensitive<\/strong>. So, lowercase letters and uppercase letters will affect the result of the comparisons you perform in your Python program.<\/p>\n\n\n\n<p>Let\u2019s say that you are building a game that tests players on their knowledge of state capitals. In order to earn points, players must correctly answer a question. So, a player may be given the state California, and in order to gain points, they would need to enter that the capital is Sacramento into the program.<\/p>\n\n\n\n<p>Here\u2019s an example of this guessing game application that compares a user\u2019s answer to the answer stored by the program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>random_state = &quot;Delaware&quot;\n\nmessage = &quot;What is the capital of &quot;, random_state\nuser_answer = input(message)\n\nstate_capital = &quot;Dover&quot;\n\nif user_answer == state_capital:\n\tprint(&quot;You are correct!&quot;)\nelse:\n\tprint(&quot;The capital of &quot;, random_state, &quot;is&quot;, state_capital)<\/pre><\/div>\n\n\n\n<p>Here\u2019s what happens when we run our guessing game and correctly guess the state capital of Delaware is Dover:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>What is the capital of Delaware\nDover\nYou are correct!<\/pre><\/div>\n\n\n\n<p>Our strings are equal, so our <code>if statement<\/code> evaluates to correct and prints out <code>You are correct!<\/code>. If we incorrectly guess the state capital is Denver, our code would return: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>What is the capital of Delaware\nDenver\nThe capital of Delaware of Dover<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. On the first one, we declare our random state, which in this case is Delaware. Then, we use the user <code>input()<\/code> method to ask the user <code>What is the capital of Delaware<\/code>.<\/p>\n\n\n\n<p>Our program then declares the state capital is Dover, and uses an <code>if<\/code> statement to compare whether the state capital the program has stored is equal to what the user has entered.&nbsp;<\/p>\n\n\n\n<p>When we entered <code>Dover<\/code>, the if statement evaluated to True, so our program printed the message <code>You are correct!<\/code> to the console. When we entered <code>Denver<\/code>, our statement evaluated to False, so our program executed the code in the <code>else<\/code> print statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python is Operator<\/h2>\n\n\n\n<p>The most common method used to compare strings is to use the <code>==<\/code> and the <code>!=<\/code> operators, which compares variables based on their values. However, if you want to compare whether two object instances are the same based on their object IDs, you may instead want to use <code>is<\/code> and <code>is not<\/code>.<\/p>\n\n\n\n<p>The difference between <code>==<\/code> and <code>is<\/code> (and <code>!=<\/code> and <code>is not<\/code>) is that the <code>==<\/code> comparison operator compares two variables based on their actual value, and the <code>is<\/code> keyword compares two variables based on their object ids.<\/p>\n\n\n\n<p>Let\u2019s use an example. Say that we have the scores of two users stored as a string, and we want to see whether or not they are the same. We could do so using the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>player_one_score = &quot;100&quot;\nplayer_two_score = &quot;100&quot;\n\nif player_one_score is player_two_score:\nprint(&quot;Player #1 and #2 have the same number of points.&quot;)\nelse:\n\tprint(&quot;Player #1 and #2 do not have the same number of points.&quot;)<\/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>Player #1 and #2 have the same number of points. <\/pre><\/div>\n\n\n\n<p>In the above code, we could also have used the <code>==<\/code> operator. However, we used the <code>is<\/code> operator instead because it uses up less memory and we only needed to compare two objects.<\/p>\n\n\n\n<p>The statement <code>player_one_score is player_two_score<\/code> evaluated to True in our program because both variables <code>player_one_score<\/code> and <code>player_two_score<\/code> have the same object IDs. We can check these IDs by using the <code>id<\/code> keyword:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(id(player_one_score))\nprint(id(player_two_score))<\/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>140239618130992\n140239618130992<\/pre><\/div>\n\n\n\n<p>As you can see, our objects are the same, and so the <code>is<\/code> operator evaluated to True. Generally, you should use <code>==<\/code> when you\u2019re comparing immutable data types like strings and numbers, and is when comparing objects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Other Comparison Operators<\/h2>\n\n\n\n<p>In addition, you can compare strings in lexicographic order using Python. Lexicographic order refers to ordering letters based on the alphabetical order of their component letters. To do so, we can use the other comparison operators offered by Python. These are as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>&lt;<\/code> &#8211; Less than<\/li><li><code>&gt;<\/code> &#8211; Greater than<\/li><li><code>&lt;=<\/code> &#8211; Less than or equal to<\/li><li><code>&gt;=<\/code> &#8211; Greater than or equal to<\/li><\/ul>\n\n\n\n<p>Let\u2019s say we were creating a program that takes in two student names and returns a message with whose name comes first in the alphabet.<\/p>\n\n\n\n<p>We could use the following code to accomplish this task:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>student_one = &quot;Penny&quot;\nstudent_two = &quot;Paul&quot;\n\nif student_one &gt; student_two:\n\tprint(&quot;Penny comes before Paul in the alphabet.&quot;)\nelif student_one &lt; student_two:\n\tprint(&quot;Paul comes before Penny in the alphabet.&quot;)<\/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>Paul comes before Penny in the alphabet.<\/pre><\/div>\n\n\n\n<p>Let\u2019s break down our code. On the first two lines, we declare two variables that store our student names. In this case, these names are Penny and Paul.<\/p>\n\n\n\n<p>Then, we create an if statement that uses the <code>greater than<\/code> operator to determine whether Penny\u2019s name comes before Paul\u2019s name in lexicographic order. If this evaluates to True, a message is printed to the console telling us that Penny comes before Paul in the alphabet.<\/p>\n\n\n\n<p>We also create an <code>elif<\/code> statement that uses the <code>less than<\/code> operator to determine whether Penny\u2019s name comes before Paul\u2019s name in the alphabet. If this evaluates to True, a message is printed to the console telling the user that Paul comes before Penny in the alphabet.<\/p>\n\n\n\n<p>In this case, Paul\u2019s name comes before Penny\u2019s in the alphabet, so the code in our <code>elif<\/code> block evaluates to true, and the message <code>Paul comes before Penny in the alphabet<\/code>. is printed to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Comparing two strings is an important feature of Python. For instance, you may be creating a login form that needs to compare the password a user has entered with the password they have set for their account.<\/p>\n\n\n\n<p>Python comparison operators can be used to compare strings in Python. These operators are: equal to (<code>==<\/code>), not equal to (<code>!=<\/code>), greater than (<code>&gt;<\/code>), less than (<code>&lt;<\/code>), less than or equal to (<code>&lt;=<\/code>), and greater than or equal to (<code>&gt;=<\/code>). This tutorial explored how these operators can be used to compare strings, and walked through a few examples of string comparison in Python.<\/p>\n\n\n\n<p>You\u2019re now ready to start comparing strings in Python like a pro!<\/p>\n","protected":false},"excerpt":{"rendered":"Strings in Python are compared with == and != operators. These compare if two Python strings are equivalent or not equivalent, respectively. They return True or False. Often, when you\u2019re working with strings in Python, you may want to compare them to each other. For example, you may want to compare a user\u2019s email address&hellip;","protected":false},"author":240,"featured_media":12886,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-12885","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":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Compare Strings: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Python includes a number of comparison operators that can be used with strings. Learn how to compare strings 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-compare-strings\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Compare Strings: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"Python includes a number of comparison operators that can be used with strings. Learn how to compare strings on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-compare-strings\/\" \/>\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-07-23T08:24:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:55:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/woman-standing-while-carrying-laptop-1181354.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-compare-strings\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Compare Strings: A Step-By-Step Guide\",\"datePublished\":\"2020-07-23T08:24:18+00:00\",\"dateModified\":\"2023-12-01T11:55:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/\"},\"wordCount\":1104,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/woman-standing-while-carrying-laptop-1181354.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/\",\"name\":\"Python Compare Strings: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/woman-standing-while-carrying-laptop-1181354.jpg\",\"datePublished\":\"2020-07-23T08:24:18+00:00\",\"dateModified\":\"2023-12-01T11:55:56+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Python includes a number of comparison operators that can be used with strings. Learn how to compare strings on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/woman-standing-while-carrying-laptop-1181354.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/woman-standing-while-carrying-laptop-1181354.jpg\",\"width\":1000,\"height\":668,\"caption\":\"A woman is standing while carrying a laptop outside a network administration bank of servers.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/python-compare-strings\\\/#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 Compare Strings: A 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\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"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 Compare Strings: A Step-By-Step Guide | Career Karma","description":"Python includes a number of comparison operators that can be used with strings. Learn how to compare strings 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-compare-strings\/","og_locale":"en_US","og_type":"article","og_title":"Python Compare Strings: A Step-By-Step Guide","og_description":"Python includes a number of comparison operators that can be used with strings. Learn how to compare strings on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-23T08:24:18+00:00","article_modified_time":"2023-12-01T11:55:56+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/woman-standing-while-carrying-laptop-1181354.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-compare-strings\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Compare Strings: A Step-By-Step Guide","datePublished":"2020-07-23T08:24:18+00:00","dateModified":"2023-12-01T11:55:56+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/"},"wordCount":1104,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/woman-standing-while-carrying-laptop-1181354.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-compare-strings\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/","url":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/","name":"Python Compare Strings: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/woman-standing-while-carrying-laptop-1181354.jpg","datePublished":"2020-07-23T08:24:18+00:00","dateModified":"2023-12-01T11:55:56+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Python includes a number of comparison operators that can be used with strings. Learn how to compare strings on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-compare-strings\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/woman-standing-while-carrying-laptop-1181354.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/woman-standing-while-carrying-laptop-1181354.jpg","width":1000,"height":668,"caption":"A woman is standing while carrying a laptop outside a network administration bank of servers."},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-compare-strings\/#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 Compare Strings: A 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\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","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\/12885","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=12885"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12885\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12886"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=12885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}