{"id":7246,"date":"2024-02-19T10:15:34","date_gmt":"2024-02-19T10:15:34","guid":{"rendered":"https:\/\/www.skillvertex.com\/blog\/?p=7246"},"modified":"2024-02-19T10:15:34","modified_gmt":"2024-02-19T10:15:34","slug":"python-continue-statement","status":"publish","type":"post","link":"https:\/\/www.skillvertex.com\/blog\/python-continue-statement\/","title":{"rendered":"Python Continue Statement"},"content":{"rendered":"\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\" id=\"rank-math-toc\"><p>Table of Contents<\/p><nav><ul><li ><a href=\"#what-is-python-continue-statement\">What is Python Continue Statement<\/a><\/li><li ><a href=\"#what-is-the-syntax-of-continue-statement\">What is the Syntax of Continue Statement<\/a><\/li><li ><a href=\"#what-are-the-examples-of-python-continue-statement\">What are the examples of Python Continue Statement?<\/a><ul><li ><a href=\"#example-1-python-continue-statement-within-a-loop\">Example 1: Python Continue Statement within a Loop<\/a><\/li><li ><a href=\"#example-2-continue-statement-with-nested-loops\">Example 2: Continue Statement With Nested Loops<\/a><\/li><li ><a href=\"#example-3-continue-statement-with-while-loop\">Example 3: Continue Statement with While Loop<\/a><\/li><\/ul><\/li><li ><a href=\"#what-are-the-uses-of-the-continue-statement\">What are the uses of the Continue Statement?<\/a><\/li><li ><a href=\"#conclusion\">Conclusion<\/a><\/li><li ><a href=\"#python-continue-statement-fa-qs\">Python Continue Statement- FAQs<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<p><a href=\"https:\/\/www.skillvertex.com\/blog\/python-for-else\/\" data-type=\"post\" data-id=\"7230\">Python<\/a> Continue Statement will ignore the execution of the <a href=\"https:\/\/www.skillvertex.com\/blog\/socket-programming-in-cpp\/\" data-type=\"post\" data-id=\"3721\">Program<\/a> and will block after the continue statement and then force the control to begin the next iteration. This article has listed the Python Continue Statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-python-continue-statement\">What is Python Continue Statement<\/h2>\n\n\n\n<p>Python <a href=\"https:\/\/www.skillvertex.com\/blog\/continue-statement-in-c\/\" data-type=\"post\" data-id=\"2295\">Continue Statement<\/a> is referred to as a <a href=\"https:\/\/www.skillvertex.com\/blog\/c-for-loop\/\" data-type=\"post\" data-id=\"2045\">Loop <\/a>control statement that can force to stop the next iteration of the loop while neglecting the rest of the code that appears inside the <a href=\"https:\/\/www.skillvertex.com\/blog\/c-loops\/\" data-type=\"post\" data-id=\"2286\">loop<\/a> for the current iteration.<\/p>\n\n\n\n<p>However, the continue statement  will <a href=\"https:\/\/www.skillvertex.com\/blog\/c-library-math-h-functions\/\" data-type=\"post\" data-id=\"2596\">function<\/a> for  both <a href=\"https:\/\/www.skillvertex.com\/blog\/do-while-loop-in-c\/\" data-type=\"post\" data-id=\"2291\">while <\/a>and loops<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-syntax-of-continue-statement\">What is the Syntax of Continue Statement<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>while True:\n    ...\n    if x == 10:\n        continue\n    print(x)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-are-the-examples-of-python-continue-statement\">What are the examples of Python Continue Statement?<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-1-python-continue-statement-within-a-loop\">Example 1: Python Continue Statement within a Loop<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Example of using continue within a loop\nnumbers = &#91;1, 2, 3, 4, 5]\n\nfor num in numbers:\n    if num % 2 == 0:\n        # Skip the even numbers and continue to the next iteration\n        continue\n    print(f\"Processing odd number: {num}\")\n\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Processing odd number: 1\nProcessing odd number: 3\nProcessing odd number: 5\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-2-continue-statement-with-nested-loops\">Example 2: Continue Statement With Nested Loops<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Example of using continue within nested loops\nfor i in range(1, 4):\n    for j in range(1, 4):\n        if j == 2:\n            # Skip the rest of the inner loop for j == 2\n            continue\n        print(f\"Outer loop: {i}, Inner loop: {j}\")\n\n\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Outer loop: 1, Inner loop: 1\nOuter loop: 1, Inner loop: 3\nOuter loop: 2, Inner loop: 1\nOuter loop: 2, Inner loop: 3\nOuter loop: 3, Inner loop: 1\nOuter loop: 3, Inner loop: 3\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-3-continue-statement-with-while-loop\">Example 3: Continue Statement with While Loop<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Example of using continue with a while loop\ni = 1\n\nwhile i &lt;= 5:\n    if i == 3:\n        # Skip the rest of the code inside the loop for i == 3\n        i += 1  # Don't forget to increment i to avoid an infinite loop\n        continue\n    print(f\"Current value of i: {i}\")\n    i += 1\n<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Current value of i: 1\nCurrent value of i: 2\nCurrent value of i: 4\nCurrent value of i: 5\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-are-the-uses-of-the-continue-statement\">What are the uses of the Continue Statement?<\/h2>\n\n\n\n<p>Loops in<a href=\"https:\/\/www.skillvertex.com\/blog\/python-for-else\/\" data-type=\"post\" data-id=\"7230\"> Python<\/a> will automate and can repeat the tasks more efficiently. Whereas, a condition may occur when you need to exit the loop and skip the iteration.<\/p>\n\n\n\n<p>Further, this process can be performed with the help of a loop control statement. The continue Statement is referred to as a type of loop control statement that can change the flow of the loop.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>In Python, the continue statement acts like a skip button for loops, allowing you to effortlessly bypass certain iterations. When faced with specific conditions, continuing enables you to jump to the next iteration, ignoring the rest of the loop code.<\/p>\n\n\n\n<p>However, It&#8217;s considered as a powerful tool for fine-tuning loops, optimizing your code, and ensuring seamless execution.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"python-continue-statement-fa-qs\">Python Continue Statement- FAQs<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1708336696355\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q1. What is the difference between pass break and continue in Python?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. The break statement will stop the entire loop as soon as the condition is found. In contrast, the continue statement will ignore the current iteration and will move to the next one.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1708336702791\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q2. What is the continue loop command in Python?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. The &#8216;while True&#8217; Statement will function to make the infinite loop in Python.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1708336710019\" class=\"rank-math-list-item\">\n<h4 class=\"rank-math-question \">Q3. What is the syntax of continue?<\/h4>\n<div class=\"rank-math-answer \">\n\n<p>Ans. The syntax of continue is  <strong>continue;<\/strong>\u00a0<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Python Continue Statement will ignore the execution of the Program and will block after the continue statement and then force the control to begin the next iteration. This article has listed the Python Continue Statement. What is Python Continue Statement Python Continue Statement is referred to as a Loop control statement that can force to &#8230; <a title=\"Python Continue Statement\" class=\"read-more\" href=\"https:\/\/www.skillvertex.com\/blog\/python-continue-statement\/\" aria-label=\"More on Python Continue Statement\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":7248,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[864],"tags":[57,922,916],"class_list":["post-7246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorial","tag-python","tag-python-continue-statement","tag-python-programming","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"_links":{"self":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/7246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/comments?post=7246"}],"version-history":[{"count":3,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/7246\/revisions"}],"predecessor-version":[{"id":7250,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/posts\/7246\/revisions\/7250"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media\/7248"}],"wp:attachment":[{"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/media?parent=7246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/categories?post=7246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skillvertex.com\/blog\/wp-json\/wp\/v2\/tags?post=7246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}