{"id":15946,"date":"2020-12-10T23:54:39","date_gmt":"2020-12-11T07:54:39","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=15946"},"modified":"2023-12-01T04:05:50","modified_gmt":"2023-12-01T12:05:50","slug":"python-for-loop","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-for-loop\/","title":{"rendered":"Python for Loop: The Complete Guide"},"content":{"rendered":"\n<p><em>A Python for loop iterates over an object until that object is complete. For instance, you can iterate over the contents of a list or a string. The for loop uses the syntax: for item in object, where &#8220;object&#8221; is the iterable over which you want to iterate.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Loops allow you to repeat similar operations in your code. One of the most common types of loops in Python is the <em>for<\/em> loop. This loop executes a block of code until the loop has iterated over an object.<\/p>\n\n\n\n<p>This tutorial will discuss the basics of for loops in Python. We&#8217;ll talk about to use the <em>range()<\/em> function and iterable objects with for loops.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Python for Loop?<\/h2>\n\n\n\n<p>A Python for loop runs a block of code until the loop has iterated over every item in an iterable. For loops help you reduce repetition in your code because they let you execute the same operation multiple times.<\/p>\n\n\n\n<p>Here is the basic structure of a <em>for<\/em> loop in Python:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for [item] in [sequence]:\n\t# Run code<\/pre><\/div>\n\n\n\n<p>Let&#8217;s look at our for loop:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>for<\/em> tells Python we want to declare a for loop.<\/li><li><em>item<\/em> tracks the individual item each iteration is viewing.<\/li><li><em>in<\/em> separates the item from the sequence.<\/li><li><em>sequence<\/em> refers to the object over which you want to iterate.<\/li><\/ul>\n\n\n\n<p>The code that is within our for loop will run until every item in our sequence has been read by our program.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python for Loops Example<\/h3>\n\n\n\n<p>You can use a for loop to run through a list of items stored in an iterable object.<\/p>\n\n\n\n<p>The term <em>iterable object<\/em> is another way of saying any object that stores a sequence of items. Here are a few types of iterable object:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/careerkarma.com\/blog\/python-dictionary\/\">Python dictionaries<\/a>.<\/li><li><a href=\"https:\/\/careerkarma.com\/blog\/python-sets\/\">Python sets<\/a>.<\/li><li><a href=\"https:\/\/careerkarma.com\/blog\/python-array\/\">Python arrays<\/a> (lists).<\/li><li><a href=\"https:\/\/careerkarma.com\/blog\/python-string-methods\/\">Python strings<\/a>.<\/li><li><a href=\"https:\/\/careerkarma.com\/blog\/python-iterator\/\">Python iterators<\/a>.<\/li><\/ul>\n\n\n\n<p>Suppose we have a list of cat breeds that we want to print out to the console individually. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>breeds = ['Persian', 'Maine Coon', 'British Shorthair', 'Ragdoll', 'Siamese']\n\nfor b in breeds:\n\tprint(b)<\/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>Persian\nMaine Coon\nBritish Shorthair\nRagdoll\nSiamese<\/pre><\/div>\n\n\n\n<p>We have specified a list as the sequence our <em>for<\/em> loop should run through. Our <em>for<\/em> loop goes through every item in our list, then prints out that item to the console.<\/p>\n\n\n\n<p>We used the <a href=\"https:\/\/careerkarma.com\/blog\/python-variables\/\">Python variable<\/a> <em>b<\/em> to refer to each item in our list. However, we could use any name for our variable, such as <em>breed<\/em> or <em>x.<\/em> The variable name must be valid. It should not have the same name as any other variable being used in our loop.<\/p>\n\n\n\n<p>You can also iterate through strings and other sequential data types like dictionaries. Suppose we wanted to print out each character in a string individually. You could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>persian = 'Persian'\n\nfor l in persian:\n\tprint(l)<\/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>P\ne\nr\ns\ni\na\nn<\/pre><\/div>\n\n\n\n<p>Our code loops through every letter in the <em>Persian<\/em> string. This is because our loop body contains a print statement that prints out each character in the string.<\/p>\n\n\n\n<p>You can add a break statement and a continue statement inside a loop. A break statement stops a loop from executing whereas a continue statement skips to the next iteration of a loop. To learn more about break and continue statements, read our guide to <a href=\"https:\/\/careerkarma.com\/blog\/python-break-and-continue\/\">Python break and continue statements<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">for Loops Python: Using range()<\/h2>\n\n\n\n<p>The <em>range()<\/em> function creates a sequence of numbers in a given range. You can use range() to specify how many times a loop should iterate. When used with len(), range() lets us create a list with a length equal to the number of values in an object.<\/p>\n\n\n\n<p>Let\u2019s use a simple example of a for loop to illustrate how this operation works. Suppose we want to print out a list of every number between 1 and 5. We could do so using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for item in range(5):\n\tprint(item)<\/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>0\n1\n2\n3\n4<\/pre><\/div>\n\n\n\n<p>In our code, we use <em>item<\/em> to keep track of the item the for loop is reading. Then, we use range(1, 6) to create a list of all numbers in the range of 1 and 6 (because range() starts counting from 0, we need to specify 6 as our high value if we want to see all numbers between 1 and 5).<\/p>\n\n\n\n<p>This function accepts three arguments, which are as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>start: The starting value at which the sequence should begin. By default, this is 0. (optional)<\/li><li>stop: The value at which the sequence should end. (required)<\/li><li>gap: The gap between each value in the sequence. By default, this is 1. (optional)<\/li><\/ul>\n\n\n\n<p>You can learn more about the <em>range()<\/em> built-in function in our <a href=\"https:\/\/careerkarma.com\/blog\/python-range\">complete guide to Python range()<\/a>.<\/p>\n\n\n\n<p>Now, suppose we want to run our loop 5 times. We could do so using this code:<\/p>\n\n\n\n<p>Our iterates over a sequence of numbers created by range() and returns:<\/p>\n\n\n\n<p>In our code, we use the <em>range()<\/em> function to specify that we want to run our <em>for<\/em> loop 5 times. Then, we print out the value of each item to the console. The <em>range()<\/em> function starts counting at 0 by default.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nested for Loops: Python<\/h2>\n\n\n\n<p>Python nested loops are loops that are executed within another loop. They are often used to iterate over the contents of lists inside lists. A nested for loop is another way of saying &#8220;a loop inside another loop.&#8221;<\/p>\n\n\n\n<p>Here is the structure of a nested for loop in Python:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>for [outer_item] in [outer_sequence]:\n\tfor [inner_item] in [inner_sequence]:\n\t\t\/\/ Run code<\/pre><\/div>\n\n\n\n<p>In a nested for loop, the program will run one iteration of the outer loop first. Then, the program will run every iteration of the inner loop, until all the code in the outer loop has been executed.<\/p>\n\n\n\n<p>Once this point is reached, the outer loop will be executed again, and this process will continue until the program has been run.<\/p>\n\n\n\n<p>Suppose we have a list of lists whose values we want to print to the console.<\/p>\n\n\n\n<p>The first list contains a list of our most popular cat breeds. Our second list contains the cat breeds we are no longer breeding. The third list contains a list of cat breeds we are thinking of breeding. We could print these lists using this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>breeds = [\n\t['Persian', 'British Shorthair', 'Siamese'],\n\t['Cornish Rex', 'Malayan', 'Maine Coon'],\n\t['Himalayan', 'Birman']\n]\n\nfor outer_list in breeds:\n\tfor breed in outer_list:\n\t\tprint(breed)<\/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>Persian\nBritish Shorthair\nSiamese\nCornish Rex\nMalayan\nMaine Coon\nHimalayan\nBirman<\/pre><\/div>\n\n\n\n<p>We have defined a list of lists called <em>breeds<\/em>. We use a nested for loop to iterate through every item in the outer list and every item in each inner list. We print out each value from our lists to the console.<\/p>\n\n\n\n<p><strong>View the Repl.it from this tutorial:<\/strong> <\/p>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/repl.it\/@careerkarma\/Python-for-Loop?lite=true\" width=\"100%\" height=\"400px\" frameborder=\"0\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Python <em>for<\/em> loops execute a block of code until the loop has iterated over every object in an iterable. <em>for<\/em> loops help reduce repetition in your code. You can iterate over lists, sets, dictionaries, strings, and any other iterable.<\/p>\n\n\n\n<p>When used with the <em>range()<\/em> statement, you can specify an exact number of times a for loop should run. If you use a <em>for<\/em> loop with an iterable object, the loop will iterate once for each item in the iterable.<\/p>\n\n\n\n<p>We have a challenge for you:<\/p>\n\n\n\n<p><em>Write a for loop that prints out all of the values in the following list to the console:<\/em><\/p>\n\n\n\n<p><em>[1, 9, 2, 3, 4]<\/em><\/p>\n\n\n\n<p><em>Once your loop prints these values, you should add a line of code into your loop that multiplies each number by two.<\/em><\/p>\n\n\n\n<p><em>Your code should return:<\/em><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>1\n2\n9\n18\n2\n4\n3\n6\n4\n8<\/pre><\/div>\n\n\n\n<p>Now you have the knowledge you need to start using for loops using the Python programming language. For advice on top online Python learning resources, courses, and books, check out our comprehensive <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-python\/\">How to Learn Python guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"A Python for loop iterates over an object until that object is complete. For instance, you can iterate over the contents of a list or a string. The for loop uses the syntax: for item in object, where \"object\" is the iterable over which you want to iterate. Loops allow you to repeat similar operations&hellip;","protected":false},"author":240,"featured_media":15947,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-15946","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.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python for Loop: The Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The Python for loop allows you to repeat similar operations in your code. On Career Karma, learn how to use the Python for loop.\" \/>\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-for-loop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python for Loop: The Complete Guide\" \/>\n<meta property=\"og:description\" content=\"The Python for loop allows you to repeat similar operations in your code. On Career Karma, learn how to use the Python for loop.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\" \/>\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-12-11T07:54:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:05:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python for Loop: The Complete Guide\",\"datePublished\":\"2020-12-11T07:54:39+00:00\",\"dateModified\":\"2023-12-01T12:05:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\"},\"wordCount\":1194,\"commentCount\":1,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\",\"name\":\"Python for Loop: The Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"datePublished\":\"2020-12-11T07:54:39+00:00\",\"dateModified\":\"2023-12-01T12:05:50+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The Python for loop allows you to repeat similar operations in your code. On Career Karma, learn how to use the Python for loop.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-for-loop\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-for-loop\/#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 for Loop: The Complete 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 for Loop: The Complete Guide | Career Karma","description":"The Python for loop allows you to repeat similar operations in your code. On Career Karma, learn how to use the Python for loop.","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-for-loop\/","og_locale":"en_US","og_type":"article","og_title":"Python for Loop: The Complete Guide","og_description":"The Python for loop allows you to repeat similar operations in your code. On Career Karma, learn how to use the Python for loop.","og_url":"https:\/\/careerkarma.com\/blog\/python-for-loop\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-12-11T07:54:39+00:00","article_modified_time":"2023-12-01T12:05:50+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.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":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python for Loop: The Complete Guide","datePublished":"2020-12-11T07:54:39+00:00","dateModified":"2023-12-01T12:05:50+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/"},"wordCount":1194,"commentCount":1,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-for-loop\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/","url":"https:\/\/careerkarma.com\/blog\/python-for-loop\/","name":"Python for Loop: The Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","datePublished":"2020-12-11T07:54:39+00:00","dateModified":"2023-12-01T12:05:50+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The Python for loop allows you to repeat similar operations in your code. On Career Karma, learn how to use the Python for loop.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-for-loop\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-for-loop\/#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 for Loop: The Complete 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\/15946","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=15946"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/15946\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/15947"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=15946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=15946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=15946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}