{"id":75272,"date":"2020-01-16T10:39:31","date_gmt":"2020-01-16T05:09:31","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=75272"},"modified":"2020-01-16T10:39:31","modified_gmt":"2020-01-16T05:09:31","slug":"python-loops","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/python-loops\/","title":{"rendered":"Python Loops &#8211; Learn one of the most powerful concepts in programming"},"content":{"rendered":"<p><strong>Loops<\/strong> are one of the most <strong>powerful<\/strong> and <strong>basic concepts<\/strong> in programming. A loop can contain a <strong>set of statements<\/strong> that keeps on <strong>executing<\/strong> until a specific condition is <strong>reached<\/strong>.<\/p>\n<p>Today, we are going to learn about the loops that are <strong>available<\/strong> in Python. In Python loops, we will study <strong>For loop<\/strong>, <strong>while loop<\/strong>, <strong>nested loops<\/strong> and<strong> loop control statements<\/strong>.<\/p>\n<h3>Python Loops<\/h3>\n<p>Let\u2019s suppose you have a task to do which is to be <strong>executed<\/strong> a thousand times.<\/p>\n<p>Here, programming languages provide us with the <strong>concept of loops<\/strong> which helps us execute some task<strong> n number of times<\/strong> where n can be any whole number. They are pretty <strong>useful<\/strong> and can be <strong>applied<\/strong> to various use cases.<\/p>\n<h4>1. Python For in loop<\/h4>\n<p>For loop in Python is used to iterate over a sequence of items like <strong>list<\/strong>, <strong>tuple<\/strong>, <strong>set<\/strong>, <strong>dictionary<\/strong>, <strong>string<\/strong> or any other <strong>iterable objects<\/strong>.<\/p>\n<p><strong>Syntax: <\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for item in sequence:\n    body of for loop<\/pre>\n<p>The Python <strong>for loop<\/strong> doesn\u2019t need <strong>indexing<\/strong> unlike other programming languages<strong> (C\/C++ or Java)<\/strong>. It works like an <strong>iterator<\/strong> and the <strong>item variable<\/strong> will contain an item from the <strong>sequence<\/strong> at each iteration.<\/p>\n<p>The <strong>for loop<\/strong> <strong>continues<\/strong> until we reach the <strong>end<\/strong> of the sequence.<\/p>\n<p><strong>Flowchart of for loop in Python<\/strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/operation-of-for-loop.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-75558 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/operation-of-for-loop.jpg\" alt=\"Flowchart of for loop in Python\" width=\"300\" height=\"374\" \/><\/a><\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for item in [1,2,3,4]:\n    print( item)<\/pre>\n<p><strong>Output: <\/strong><\/p>\n<div class=\"code-output\">1<br \/>\n2<br \/>\n3<br \/>\n4<\/div>\n<h5>a. The range() function<\/h5>\n<p>When using <strong>for loops<\/strong> in Python, the <strong>range()<\/strong> function is pretty useful to <strong>specify the number of times<\/strong> the <strong>loop is executed<\/strong>. It yields a <strong>sequence of numbers<\/strong> within a <strong>specified range<\/strong>.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">range(start, stop, step)<\/pre>\n<ul>\n<li>The first argument is the <strong>starting value<\/strong>. It is <strong>zero<\/strong> by default.<\/li>\n<li>The second argument is the <strong>ending value<\/strong> of the range.<\/li>\n<li>The third argument is the <strong>number of steps<\/strong> to take after each yield.<\/li>\n<\/ul>\n<p><strong>#converting range to list<\/strong><\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">list(range(10))\nlist(range(4,10))\nlist(range(2,10,2))<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],<br \/>\n[4, 5, 6, 7, 8, 9],<br \/>\n[2, 4, 6, 8]<\/div>\n<h5>b. Iterating over range object<\/h5>\n<p>You can use the <strong>for loop<\/strong> to iterate over the <strong>range of objects<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for i in range(2,20,2):\n  print(i)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">2<br \/>\n4<br \/>\n6<br \/>\n8<br \/>\n10<br \/>\n12<br \/>\n14<br \/>\n16<br \/>\n18<\/div>\n<p>Similarly, we can <strong>iterate<\/strong> the same way in <strong>tuples<\/strong>, <strong>lists<\/strong>, <strong>sets<\/strong>, and <strong>strings<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for char in \u201cHello\u201d:\n  print(char)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">H<br \/>\ne<br \/>\nl<br \/>\nl<br \/>\no<br \/>\n&#8212;<\/div>\n<h5>c. Using else in for loop<\/h5>\n<p>In Python programming, the loops can also have an <strong>else<\/strong> part which will be <strong>executed<\/strong> once when the <strong>loop terminates<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for i in [1, 2, 3, 4]:\n  print(i)\nelse:\n  print(\u201cThe loop ended\u201d)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\nThe loop ended<\/div>\n<h4>2. Python While loop<\/h4>\n<p>The <strong>while loop<\/strong> in Python <strong>executes a block of code<\/strong> until the <strong>specified condition<\/strong> becomes <strong>False<\/strong>.<\/p>\n<p><strong>Flowchart of while loop in Python<\/strong><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/python-while-loop.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-75559 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/python-while-loop.jpg\" alt=\"Flowchart of while loop in Python\" width=\"314\" height=\"309\" \/><\/a><\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">while( condition):\n  Body of while\n  Inside while block<\/pre>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">count = 0\nwhile( count&lt; 10):\n  print(count)\n  count = count + 2<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0<br \/>\n2<br \/>\n4<br \/>\n6<br \/>\n8<\/div>\n<p>In the example, the while statement checks if count is <strong>less than<\/strong> <strong>10<\/strong>.<\/p>\n<p>Initially, <strong>count<\/strong> is <strong>zero<\/strong> so the statement is <strong>true<\/strong> and it <strong>executes<\/strong> the <strong>body of while<\/strong>. Then the count gets <strong>incremented<\/strong> by <strong>2<\/strong>. Again we check the condition and this goes on till the <strong>condition becomes false<\/strong>.<\/p>\n<p>Here, when our code checks<strong> 10&lt;10<\/strong>, the statement returns <strong>False<\/strong> and so the code in <strong>while block<\/strong> is <strong>not executed<\/strong>.<\/p>\n<h5>a. Infinite loop<\/h5>\n<p>A loop is called an infinite loop when the loop will <strong>never reach its end<\/strong>.<\/p>\n<p>Usually, when a condition is always <strong>True<\/strong> in a <strong>while loop<\/strong>, the loop will become an <strong>infinite loop<\/strong>. So we should be careful when <strong>writing conditions<\/strong> and while <strong>updating variables<\/strong> used in the <strong>loop<\/strong>.<\/p>\n<p>In Python shell, we can the program on an <strong>infinite loop<\/strong> by using <strong>CTRL + C<\/strong>. Sometimes, we need to implement an infinite\u00a0<strong>terminate<\/strong>\u00a0<strong>loop<\/strong> for example, when reading <strong>frames<\/strong> from a <strong>webcam<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">while (True):\n    print(\u201cInfinite Loop\u201d)<\/pre>\n<p>This code will keep on printing the<strong> \u201cInfinite Loop\u201d<\/strong> statement. We <strong>terminate<\/strong> the loop by pressing<strong> CTRL + C.<\/strong><\/p>\n<h5>b. Using else in while loop<\/h5>\n<p>The while loop may also have an <strong>else part<\/strong> after the <strong>loop<\/strong>. It is executed only when the <strong>condition<\/strong> of <strong>while loop<\/strong> becomes <strong>false<\/strong>. But if we <strong>break<\/strong> out of the <strong>loop<\/strong> before the <strong>condition<\/strong> has <strong>not reached<\/strong> <strong>false,<\/strong> then the<strong> else block<\/strong> does not get <strong>executed<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">num = 0\nwhile( num&lt;10 ):\n    print(num)\n    num += 1\n    if( num==5):\n        break\nelse:\n    print('Loop ended')<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<\/div>\n<p>Here the else statement didn\u2019t get executed because the break statement <strong>ends <\/strong>the <strong>loop execution<\/strong> and the while condition therefore never becomes <strong>false<\/strong>.<\/p>\n<h4>3. Python Nested Loops<\/h4>\n<p>We can nest a <strong>loop inside<\/strong> another <strong>loop<\/strong> which simply means that a <strong>loop within a loop<\/strong>. Let\u2019s see this with an example.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">for num1 in range(3):\n    for num2 in range(5, 8):\n        print(num1, \",\", num2)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0 , 5<br \/>\n0 , 6<br \/>\n0 , 7<br \/>\n1 , 5<br \/>\n1 , 6<br \/>\n1 , 7<br \/>\n2 , 5<br \/>\n2 , 6<br \/>\n2 , 7<\/div>\n<p>From this example, you can observe that the <strong>first iteration<\/strong> of the <strong>outer loop<\/strong> will <strong>run<\/strong> the <strong>whole inner loop<\/strong> and then in the next <strong>iteration<\/strong> of the <strong>outer loop<\/strong>, the <strong>inner loop<\/strong> gets <strong>executed again<\/strong>. This process is <strong>repeated<\/strong> until we reach the <strong>end<\/strong> of the <strong>outer loop<\/strong>.<\/p>\n<h4>4. Loop Control Statements in Python<a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/loop-control-statement-in-python.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-75567 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/01\/loop-control-statement-in-python.jpg\" alt=\"python loop control statements\" width=\"642\" height=\"338\" \/><\/a><\/h4>\n<p>&nbsp;<\/p>\n<p>Python allows us to <strong>control the flow<\/strong> of the <strong>execution<\/strong> of the program in a <strong>certain manner<\/strong>. For this we use the <strong>continue<\/strong>, <strong>break<\/strong> and <strong>pass keywords<\/strong>.<\/p>\n<h4>a. break<\/h4>\n<p>The break statement <strong>inside a loop<\/strong> is used to <strong>exit<\/strong> out of the <strong>loop<\/strong>. Sometimes in a program, we need to <strong>exit the loop<\/strong> when a certain <strong>condition<\/strong> is <strong>fulfilled<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">num = 0\nwhile( num &lt;10 ):\n    num +=1\n    if(num==5): break\n    print( num )\n\nprint(\"Loop ended\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\nLoop ended<\/div>\n<p>In this loop, we are <strong>incrementing<\/strong> the value of <strong>num<\/strong> <strong>variable<\/strong> and then printing it. When the num value becomes <strong>5<\/strong> the <strong>break statement<\/strong> is <strong>executed<\/strong> which <strong>terminates<\/strong> the loop and therefore <strong>loop<\/strong> is not <strong>executed further<\/strong>.<\/p>\n<h4>b. continue<\/h4>\n<p>The continue statement is used to <strong>skip<\/strong> the next <strong>statements<\/strong> in the <strong>loop<\/strong>.<\/p>\n<p>When the program reaches the continue statement, the program <strong>skips <\/strong>the <strong>statements<\/strong> after <strong>continue<\/strong> and the flow reaches the <strong>next iteration<\/strong> of the <strong>loop<\/strong>.<\/p>\n<p>Let\u2019s take the same example &#8211;<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">num = 0\nwhile( num &lt;10 ):\n    num +=1\n    if(num==5): continue\n    print( num )\n\nprint(\"Loop ended\")<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<br \/>\n10<br \/>\nLoop ended<\/div>\n<p>Here, we see that when the <strong>num<\/strong> variable is equal to <strong>5<\/strong>, the <strong>continue statement<\/strong> is <strong>executed<\/strong>. It then <strong>doesn\u2019t execute<\/strong> the lines after the <strong>continue statement<\/strong> and the <strong>control<\/strong> is sent to the <strong>next iteration<\/strong>.<\/p>\n<h4>c. pass<\/h4>\n<p>The pass is a <strong>null statement<\/strong> and the <strong>Python interpreter<\/strong> returns a <strong>no-operation (NOP)<\/strong> after reading the <strong>pass statement<\/strong>. Nothing happens when the pass statement is <strong>executed<\/strong>. It is used as a <strong>placeholder<\/strong> when implementing <strong>new methods<\/strong> or we can use them in <strong>exception handling<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">nums = [1,2,3,4]\nfor num in nums:\n  pass\n\nprint(nums)<\/pre>\n<h3>Summary<\/h3>\n<p>To sum up, we learned how the concepts of <strong>loops<\/strong> are useful for us programmers to do <strong>repetitive tasks<\/strong> effectively with the help of loops. We saw <strong>examples<\/strong> and <strong>syntax<\/strong> of different types of Python loops, which are <strong>for loop<\/strong> and <strong>while loop<\/strong>. We also saw that we can use <strong>else statements<\/strong> with a for or while loop.<\/p>\n<p>Moreover, we saw <strong>nested loop<\/strong> and <strong>loop control statements<\/strong> which helps to change the <strong>normal flow<\/strong> of the loop.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Loops are one of the most powerful and basic concepts in programming. A loop can contain a set of statements that keeps on executing until a specific condition is reached. Today, we are going&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":75561,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[1314,1315,1316,1317,1318,1319,1320,1321],"class_list":["post-75272","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-flowchart-of-for-loop-in-python","tag-flowchart-of-while-loop-in-python","tag-loop-control-statements-in-python","tag-loops-in-python","tag-python-for-in-loop","tag-python-loops","tag-python-nested-loops","tag-python-while-loop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Loops - Learn one of the most powerful concepts in programming - TechVidvan<\/title>\n<meta name=\"description\" content=\"Python Loops - Learn different types of loops that are available in Python such as for loop, while loop, nested loop, etc with flowcharts and examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/python-loops\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Loops - Learn one of the most powerful concepts in programming - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Python Loops - Learn different types of loops that are available in Python such as for loop, while loop, nested loop, etc with flowcharts and examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/python-loops\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-16T05:09:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-loops.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Loops - Learn one of the most powerful concepts in programming - TechVidvan","description":"Python Loops - Learn different types of loops that are available in Python such as for loop, while loop, nested loop, etc with flowcharts and examples.","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:\/\/techvidvan.com\/tutorials\/python-loops\/","og_locale":"en_US","og_type":"article","og_title":"Python Loops - Learn one of the most powerful concepts in programming - TechVidvan","og_description":"Python Loops - Learn different types of loops that are available in Python such as for loop, while loop, nested loop, etc with flowcharts and examples.","og_url":"https:\/\/techvidvan.com\/tutorials\/python-loops\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-01-16T05:09:31+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-loops.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Python Loops &#8211; Learn one of the most powerful concepts in programming","datePublished":"2020-01-16T05:09:31+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/"},"wordCount":1037,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-loops.jpg","keywords":["Flowchart of for loop in Python","Flowchart of while loop in Python","Loop Control Statements in Python","loops in python","Python For in loop","Python loops","Python Nested Loops","Python While loop"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/python-loops\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/","url":"https:\/\/techvidvan.com\/tutorials\/python-loops\/","name":"Python Loops - Learn one of the most powerful concepts in programming - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-loops.jpg","datePublished":"2020-01-16T05:09:31+00:00","description":"Python Loops - Learn different types of loops that are available in Python such as for loop, while loop, nested loop, etc with flowcharts and examples.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/python-loops\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-loops.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/01\/python-loops.jpg","width":802,"height":420,"caption":"loops in python"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/python-loops\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Python Loops &#8211; Learn one of the most powerful concepts in programming"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=75272"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/75272\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/75561"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=75272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=75272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=75272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}