{"id":12258,"date":"2020-05-24T16:03:17","date_gmt":"2020-05-24T23:03:17","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12258"},"modified":"2023-12-01T02:48:08","modified_gmt":"2023-12-01T10:48:08","slug":"python-list-methods","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-list-methods\/","title":{"rendered":"Python List Methods: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>Lists are a built-in data structure in Python 3. Python Lists can be used to organize and store data in an ordered way, such as names of suppliers for a manufacturing company, salary information for a company\u2019s employees, a list of student grades, or anything else.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>There are a number of built-in functions in Python that we can use to change or manipulate data that is stored in lists.<\/p>\n\n\n\n<p>In this guide, we are going to break down some of the most useful built-in methods that can be used to work with lists. We\u2019ll explore how to add and remove elements from a list, count the elements in a list, reverse a list, and more.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">List Refresher<\/h2>\n\n\n\n<p>Lists are a data type in Python that are mutable, ordered arrangements of items. This means that lists can be changed, and store data in a specific order.<\/p>\n\n\n\n<p>Each element within a list is called an <code>item<\/code>, and lists are defined by comma-separated values enclosed within square brackets (<code>[]<\/code>).<\/p>\n\n\n\n<p>Here\u2019s how to create a list in Python: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>news_sites = [\"New York Times\", \"Washington Post\", \"CNN\", \"BuzzFeed\"]<\/pre><\/div>\n\n\n\n<p>In order to print out our list, we can use the <code>print()<\/code> function:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(news_sites)<\/pre><\/div>\n\n\n\n<p>Our program returns our original array as we defined it: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>['New York Times', 'Washington Post', 'CNN', 'BuzzFeed']<\/pre><\/div>\n\n\n\n<p>In order to retrieve a specific element from a Python list, we must reference the index of the element. Each item in a list has an index number, starting with <code>0<\/code>, which allows us to retrieve the contents of an individual element. Here are the index values for the list we created above:<\/p>\n\n\n\n<figure class=\"wp-block-table course-info-table\"><table><tbody><tr><td>New York Times<\/td><td>Washington Post<\/td><td>CNN<\/td><td>BuzzFeed<\/td><\/tr><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Now that we know the index numbers of our list elements, we can retrieve a specific value from our list. To do so, we can use the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(news_sites[0])<\/pre><\/div>\n\n\n\n<p>Our code returns: <code>New York Times<\/code>. Similarly, if we referenced the list item with the index value of <code>2<\/code>, our code would return <code>CNN<\/code>. <\/p>\n\n\n\n<p>Each item in our list also has a negative index number. This allows us to count backward on a list and is useful if our list contains a large number of values and we want to retrieve a value toward the end of that list.<\/p>\n\n\n\n<p>Here are the negative index values for our list above:<\/p>\n\n\n\n<figure class=\"wp-block-table course-info-table\"><table><tbody><tr><td>New York Times<\/td><td>Washington Post<\/td><td>CNN<\/td><td>BuzzFeed<\/td><\/tr><tr><td>-4<\/td><td>-3<\/td><td>-2<\/td><td>-1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>If we wanted to get the item at the index position <code>-1<\/code>, we could use this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(news_sites[-1])<\/pre><\/div>\n\n\n\n<p>Our code returns: <code>BuzzFeed<\/code>.<\/p>\n\n\n\n<p>Now that we have covered the basics of Python lists, we can start to explore Python\u2019s list methods. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Add Elements Using list.append()<\/strong><\/h2>\n\n\n\n<p>The <code>list.append()<\/code> method allows you to add an item to the end of a list. Here\u2019s an example of a list that stores pizza flavors:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors = [\"Ham and Pineapple\", \"Cheese\", \"Mexican\", \"Chicken\", \"Pepperoni\"]<\/pre><\/div>\n\n\n\n<p>Our list consists of five values, starting with the index value <code>0<\/code>, and ending with the index value <code>4<\/code>. But what if we want to add a meat-lovers option to our list? We can use the <code>append()<\/code> method to perform this action.&nbsp;<\/p>\n\n\n\n<p>Here\u2019s an example of <code>append()<\/code> being used to add <code>Meat-Lovers<\/code> to our list:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors.append(\"Meat-Lovers\")\nprint(flavors)<\/pre><\/div>\n\n\n\n<p>Our code returns our revised list with <code>Meat-Lovers<\/code> at the end: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>['Ham and Pineapple', 'Cheese', 'Mexican', 'Chicken', 'Pepperoni', 'Meat-Lovers']<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Insert into List Using list.insert()<\/h2>\n\n\n\n<p> The <code>append()<\/code> method allows you to add an item to the end of a list, but if you want to add an item at a specific index position, the <code>insert()<\/code> method will insert an item at any place in a list.<\/p>\n\n\n\n<p>Let\u2019s say that our pizza chef has been cooking up an in-house special with Jalapeno peppers and is ready to add it to the menu. The chef wants this pizza to come at the top of our list of flavors, to encourage new customers to try out the pizza.<\/p>\n\n\n\n<p>We can use the <code>insert()<\/code> method to accomplish this goal. The <code>insert()<\/code> method takes two arguments: the index position at which you would like to add the item and the item you want to add to your list. Here\u2019s an example of <code>insert()<\/code> being used to add <code>Jalapeno Special<\/code> to the start of the flavors list: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors.insert(0, \"Jalapeno Special\")\nprint(flavors)<\/pre><\/div>\n\n\n\n<p>Our code returns the following list: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>['Jalapeno Special', 'Ham and Pineapple', 'Cheese', 'Mexican', 'Chicken', 'Pepperoni', 'Meat-Lovers']<\/pre><\/div>\n\n\n\n<p>As you can see, <code>Jalapeno Special<\/code> was added to the start of our list, and was assigned the index number <code>0<\/code>. Every other item in our list moved up, and so they are given new index numbers corresponding to their new position in the list. <code>Ham and Pineapple<\/code>, for example, now has the index value <code>1<\/code>, and so on. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remove From List Using list.remove()<\/h2>\n\n\n\n<p>In order to remove an item from a Python list, we can use the <code>list.remove()<\/code> method. This method removes the first item from a list whose value is equal to the value we specify.<\/p>\n\n\n\n<p>After a week of trialing the <code>Jalapeno Special<\/code>, it has been made clear that the pizza kitchen\u2019s customers are not in favor of the flavor. So the chef would like to remove it from the menu while he tinkers with the recipe. We could use the following code to remove <code>Jalapeno Special<\/code> from our list:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors.remove(\"Jalapeno Special\")\nprint(flavors)<\/pre><\/div>\n\n\n\n<p>Our code returns a revised list without <code>Jalapeno Special<\/code>: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>['Ham and Pineapple', 'Cheese', 'Mexican', 'Chicken', 'Pepperoni', 'Meat-Lovers']<\/pre><\/div>\n\n\n\n<p>There are a few things you should know about the <code>remove()<\/code> method. Firstly, if you try to remove an item that does not exist within a list, an error <code>not in list.<\/code> will appear. Secondly, the <code>remove()<\/code> method only removes the first instance of a list item. If you had two <code>Jalapeno Specials<\/code> in your list, you would have to run the <code>remove()<\/code> method twice to remove them both. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remove from List Using list.pop()<\/h2>\n\n\n\n<p>The <code>list.pop()<\/code> method can be used to remove and return an item from a list.<\/p>\n\n\n\n<p>The <code>pop()<\/code> method takes one optional argument: the index value of the element we want to remove from our list. If we don\u2019t specify an index, <code>pop()<\/code> will return and remove the last item in our list.<\/p>\n\n\n\n<p>Our pizza kitchen has decided that the <code>Meat-Lovers<\/code> pizza should be moved to the special menu, which includes the chef\u2019s new range of experimental pizzas. So the chef wants to remove <code>Meat-Lovers<\/code> from the list of flavors for pizzas.<\/p>\n\n\n\n<p>Here\u2019s the code we would use to remove <code>Meat-Lovers<\/code> (which has the index value <code>5<\/code>, from our list): <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors = [\"Ham and Pineapple\", \"Cheese\", \"Mexican\", \"Chicken\", \"Pepperoni\", \"Meat-Lovers\"]\nprint(flavors.pop(5))\nprint(flavors)<\/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>Meat-Lovers\n['Ham and Pineapple', 'Cheese', 'Mexican', 'Chicken', 'Pepperoni']<\/pre><\/div>\n\n\n\n<p>As you can see, the <code>pop()<\/code> function removed the value we specified and returned the value of the list item we removed, which in this case was <code>Meat-Lovers<\/code>. Then, we printed out the new list, which no longer includes <code>Meat-Lovers<\/code>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Combine Multiple Lists Using list.extend()<\/h2>\n\n\n\n<p>The <code>list.extend()<\/code> method can be used to combine multiple lists in Python. The <code>extend()<\/code> method takes one argument: the list object you want to add to an existing list.<\/p>\n\n\n\n<p>Our pizza chef has decided that the special menu should be merged with the standard menu because customers have reported being confused with the two separate menus. In order to merge both our menus, we would use the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors = [\"Ham and Pineapple\", \"Cheese\", \"Mexican\", \"Chicken\", \"Pepperoni\"]\nspecial_menu = [\"Meat-Lovers\", \"BBQ Chicken\", \"Sausage and Pepperoni\", \"Vegetarian Special\", \"Greek\"]\nflavors.extend(special_menu)\nprint(flavors)<\/pre><\/div>\n\n\n\n<p>Our program returns the following: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>['Ham and Pineapple', 'Cheese', 'Mexican', 'Chicken', 'Pepperoni', 'Meat-Lovers', 'BBQ Chicken', 'Sausage and Pepperoni', 'Vegetarian Special', 'Greek']<\/pre><\/div>\n\n\n\n<p>As you can see, our <code>flavors<\/code> list now includes items from both our old flavors list, and our <code>special_menu<\/code> list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Copy a List Using list.copy()<\/h2>\n\n\n\n<p>The <code>list.copy()<\/code> method allows you to create a copy of a list. This can be useful if you want to manipulate a list but keep the original list intact, in case you need to reference it again.<\/p>\n\n\n\n<p>Our pizza chef has decided to experiment with the menu even further, adding two new pizzas to the menu. However, he wants to keep a list of the original menu for reference.<\/p>\n\n\n\n<p>We could use the following code to create a copy of the menu, which he can add his new pizzas to while preserving the original list:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>new_menu = menu.copy()\nprint(menu)<\/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>['Ham and Pineapple', 'Cheese', 'Mexican', 'Chicken', 'Pepperoni', 'Meat-Lovers', 'BBQ Chicken', 'Sausage and Pepperoni', 'Vegetarian Special', 'Greek']<\/pre><\/div>\n\n\n\n<p>Now, we have two lists with the same values: <code>flavors<\/code> and <code>new_menu<\/code>. So, the chef can alter the <code>new_menu<\/code>, while still keeping the <code>flavors<\/code> list intact. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sort a List Using list.sort()<\/h2>\n\n\n\n<p>The <code>list.sort()<\/code> method can be used to sort items in a list.<\/p>\n\n\n\n<p>Our chef has decided that our list should be sorted in alphabetical order, to make it easier for people to find the pizza they are looking for. The following code <code>uses sort()<\/code> to arrange our list in alphabetical order:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors.sort()\nprint(flavors)<\/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>['BBQ Chicken', 'Cheese', 'Chicken', 'Greek', 'Ham and Pineapple', 'Meat-Lovers', 'Mexican', 'Pepperoni', 'Sausage and Pepperoni', 'Vegetarian Special']<\/pre><\/div>\n\n\n\n<p>You can also use the <code>sort()<\/code> function on a list of numbers, too, which will be arranged in ascending order. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reverse a List Using list.reverse()<\/h2>\n\n\n\n<p>The <code>list.reverse()<\/code> method can be used to reverse the order of items in a list.<\/p>\n\n\n\n<p>This function does not sort a list in descending order but instead flips the order of every item in our list. So the last item in our list becomes the first item in our new list, and the second-last item becomes the second item, and so on.<\/p>\n\n\n\n<p>Our pizza chef has decided that he wants the list of pizzas to be arranged in descending order, because he has noticed a growth in the number of sales from the bottom of the menu. Here\u2019s the code we would use to reverse our list:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>flavors = ['BBQ Chicken', 'Cheese', 'Chicken', 'Greek', 'Ham and Pineapple', 'Meat-Lovers', 'Mexican', 'Pepperoni', 'Sausage and Pepperoni', 'Vegetarian Special']\nflavors.reverse()\nprint(flavors)<\/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>['Vegetarian Special', 'Sausage and Pepperoni', 'Pepperoni', 'Mexican', 'Meat-Lovers', 'Ham and Pineapple', 'Greek', 'Chicken', 'Cheese', 'BBQ Chicken']<\/pre><\/div>\n\n\n\n<p>As you can see, <code>Vegetarian Special<\/code> was the last item in our original list, and now it is the first\u2014our list has been reversed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Clear a List Using list.clear()<\/h2>\n\n\n\n<p>The <code>list.clear()<\/code> method allows you to remove all values within a list.<\/p>\n\n\n\n<p>The new month has come upon the pizza kitchen, and so the chef wants to clear the list of sales for January and start a new list for February. Here\u2019s the code that could be used to clear our <code>sales<\/code> list to make room for February: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>sales.clear()\nprint(sales)<\/pre><\/div>\n\n\n\n<p> Our code returns a list with no values: <code>[]<\/code>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Lists are mutable, ordered arrangements of items that can be used to store similar data. In this tutorial, we have broken down some of the most common Python list methods, which can be used to manipulate our lists and gather insights about the data in our list.<\/p>\n\n\n\n<p>We covered how to use <code>append()<\/code>, <code>insert()<\/code>, <code>remove()<\/code>, <code>pop()<\/code>, <code>extend()<\/code>, <code>copy()<\/code>, <code>sort()<\/code>, <code>reverse()<\/code>, and <code>clear()<\/code> list methods in this article, and explored examples of each method in action.<\/p>\n\n\n\n<p>Now you\u2019re ready to work with Python list methods like an expert!<\/p>\n","protected":false},"excerpt":{"rendered":"Lists are a built-in data structure in Python 3. Python Lists can be used to organize and store data in an ordered way, such as names of suppliers for a manufacturing company, salary information for a company\u2019s employees, a list of student grades, or anything else. There are a number of built-in functions in Python&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-12258","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 List Methods: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Python has a number of built-in list methods that can be used to change the items in a list. Learn about list 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-list-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python List Methods: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"Python has a number of built-in list methods that can be used to change the items in a list. Learn about list methods on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-list-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-05-24T23:03:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:48:08+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-list-methods\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-methods\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python List Methods: A Step-By-Step Guide\",\"datePublished\":\"2020-05-24T23:03:17+00:00\",\"dateModified\":\"2023-12-01T10:48:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-methods\/\"},\"wordCount\":1609,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-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-list-methods\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-methods\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-list-methods\/\",\"name\":\"Python List Methods: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-methods\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-methods\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg\",\"datePublished\":\"2020-05-24T23:03:17+00:00\",\"dateModified\":\"2023-12-01T10:48:08+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Python has a number of built-in list methods that can be used to change the items in a list. Learn about list methods on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-methods\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-list-methods\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-list-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-list-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 List Methods: 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\/#\/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 List Methods: A Step-By-Step Guide | Career Karma","description":"Python has a number of built-in list methods that can be used to change the items in a list. Learn about list 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-list-methods\/","og_locale":"en_US","og_type":"article","og_title":"Python List Methods: A Step-By-Step Guide","og_description":"Python has a number of built-in list methods that can be used to change the items in a list. Learn about list methods on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/python-list-methods\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-05-24T23:03:17+00:00","article_modified_time":"2023-12-01T10:48:08+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-list-methods\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-list-methods\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python List Methods: A Step-By-Step Guide","datePublished":"2020-05-24T23:03:17+00:00","dateModified":"2023-12-01T10:48:08+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-list-methods\/"},"wordCount":1609,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-list-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-list-methods\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-list-methods\/","url":"https:\/\/careerkarma.com\/blog\/python-list-methods\/","name":"Python List Methods: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-list-methods\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-list-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-string-methods.jpg","datePublished":"2020-05-24T23:03:17+00:00","dateModified":"2023-12-01T10:48:08+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Python has a number of built-in list methods that can be used to change the items in a list. Learn about list methods on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-list-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-list-methods\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-list-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-list-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 List Methods: 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\/#\/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\/12258","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=12258"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12258\/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=12258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}