{"id":18926,"date":"2021-12-07T09:01:23","date_gmt":"2021-12-07T03:31:23","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=18926"},"modified":"2023-07-12T18:12:18","modified_gmt":"2023-07-12T12:42:18","slug":"python-while-loop-multiple-conditions-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/","title":{"rendered":"Python while loop multiple conditions | Example code"},"content":{"rendered":"\n<p>Use <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-operators-overview-examples\/\">logical operator <\/a>for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while loop.<\/p>\n\n\n\n<p><strong>Logical AND Operator<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while ( CONDITIONAL EXPRESSION A ) and ( CONDITIONAL EXPRESSION B ):\n\tEXECUTE STATEMENTS<\/code><\/pre>\n\n\n\n<p><strong>Logical OR Operator<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while ( CONDITIONAL EXPRESSION A ) or ( CONDITIONAL EXPRESSION B ):\n\tEXECUTE STATEMENTS<\/code><\/pre>\n\n\n\n<p><strong>Logical NOT Operator<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while ( not CONDITIONAL EXPRESSION ):\n\tEXECUTE STATEMENTS<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example while loop multiple conditions in Python<\/strong><\/h2>\n\n\n\n<p>Simple example code.<\/p>\n\n\n\n<p><strong>Using AND &amp;<\/strong><\/p>\n\n\n\n<p>If (and only if) both A and B are true, then the loop body will execute.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = 1\nb = 2\ncount = 0\n\nwhile count &lt; a and count &lt; b:\n    print(a, b)\n    count += 1\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: 1 2<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using OR |<\/strong><\/p>\n\n\n\n<p>The loop body will execute if <em>at least<\/em> one of the <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-ternary-operator-conditional-expressions\/\">conditional expressions<\/a> is true.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = 1\nb = 2\ncount = 0\n\nwhile count &lt; a or count &lt; b:\n    print(a, b)\n    count += 1\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<p>1 2<br>1 2<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using NOT Operator<\/strong><\/p>\n\n\n\n<p>This operator simply reverses the value of a given boolean expression<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>is_valid = False\r\n\r\nwhile not is_valid:\r\n    password = input(\"Enter your password: \")\r\n    if password == \"password123\":\r\n        is_valid = True\r\n    else:\r\n        print(\"Invalid password. Try again.\")\r\n\r\nprint(\"Login successful!\")\r<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Multiple Conditions<\/strong><\/p>\n\n\n\n<p>The loop will continue executing as long as either of the conditions <code>(count &lt; a or count &lt; b)<\/code> is true and the count is less than <code>max_iterations<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = 1\nb =2\n\nmax_iterations = 3\ncount = 0\n\nwhile (count &lt; a or count &lt; b) and not count &gt;= max_iterations:\n    print(f\"count: {count}, a: {a}, b: {b}\")\n    count += 1\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"133\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg?resize=306%2C133&#038;ssl=1\" alt=\"Python while loop multiple conditions\" class=\"wp-image-22973\"\/><\/figure><\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts or suggestions on this Python while loop topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong> IDE:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>&nbsp;2021.3.3 (Community Edition)<\/p><p>Windows 10<\/p><p><strong>Python 3.10.1<\/strong><\/p><p>All<strong>&nbsp;Python Examples&nbsp;are in&nbsp;Python&nbsp;3<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Use logical operator for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while loop. Logical AND Operator Logical OR Operator Logical NOT Operator Example while loop multiple conditions in Python Simple example code. Using AND &amp; If (and only if) both A and B are true, then the&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Python while loop multiple conditions | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[36,170],"post_series":[],"class_list":["post-18926","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-loops","tag-python-while"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python while loop multiple conditions | Example code<\/title>\n<meta name=\"description\" content=\"Use logical operator for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while 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:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python while loop multiple conditions | Example code\" \/>\n<meta property=\"og:description\" content=\"Use logical operator for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while loop.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-07T03:31:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-12T12:42:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/\",\"name\":\"Python while loop multiple conditions | Example code\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg\",\"datePublished\":\"2021-12-07T03:31:23+00:00\",\"dateModified\":\"2023-07-12T12:42:18+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Use logical operator for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while loop.\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg?fit=306%2C133&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg?fit=306%2C133&ssl=1\",\"width\":306,\"height\":133},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python while loop multiple conditions | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python while loop multiple conditions | Example code","description":"Use logical operator for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while 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:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/","og_locale":"en_US","og_type":"article","og_title":"Python while loop multiple conditions | Example code","og_description":"Use logical operator for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while loop.","og_url":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-12-07T03:31:23+00:00","article_modified_time":"2023-07-12T12:42:18+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/","name":"Python while loop multiple conditions | Example code","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg","datePublished":"2021-12-07T03:31:23+00:00","dateModified":"2023-07-12T12:42:18+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Use logical operator for Python while looping multiple conditions. With it, you can combine two conditional expressions into one while loop.","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg?fit=306%2C133&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/12\/Python-while-loop-multiple-conditions.jpg?fit=306%2C133&ssl=1","width":306,"height":133},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-multiple-conditions-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Python while loop multiple conditions | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777979855","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":18928,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-while-2-conditions-example-code\/","url_meta":{"origin":18926,"position":0},"title":"Python while 2 conditions | Example code","author":"Rohit","date":"September 2, 2021","format":false,"excerpt":"Use logical operators to combine two conditional expressions into one while loop in Python. In the same way, you can use Multiple condition expressions in a while loop. For example while 2 conditions in Python Simple example code combines multiple conditional expressions in a while loop. We will do use\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python while 2 conditions","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/09\/Python-while-2-conditions.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17182,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-conditional-expression-basics\/","url_meta":{"origin":18926,"position":1},"title":"Python conditional expression | Basics","author":"Rohit","date":"November 3, 2021","format":false,"excerpt":"Python has conditional expressions which are sometimes called a \"ternary operator\". If you need to use statements, you have to use a normal if statement instead of a conditional expression. In Python, the conditional expression is written as follows. X if condition else Y Python conditional expression example Simple example\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python conditional expression","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-conditional-expression.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":18642,"url":"https:\/\/tutorial.eyehunts.com\/python\/logical-operators-in-python\/","url_meta":{"origin":18926,"position":2},"title":"Logical operators in Python","author":"Rohit","date":"October 12, 2022","format":false,"excerpt":"Python Logical operators are used to combine conditional statements. Python has three Logical operators the and, or, not operators. OperatorMeaningExampleandTrue if both the operands are truex and yorTrue if either of the operands is truex or ynotTrue if operand is false (complements the operand)not x Logical operators in Python Simple\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Logical operators in Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/10\/Logical-operators-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":7547,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-ternary-operator-conditional-expressions\/","url_meta":{"origin":18926,"position":3},"title":"Python Ternary Operator | conditional expressions","author":"Rohit","date":"February 12, 2020","format":false,"excerpt":"Python ternary operators or conditional expressions are used to evaluate something based on a condition being true or false. See the below The expression syntax of it. \u00a0Ternary Operator was\u00a0added\u00a0in python version 2.5. Syntax a if condition else b Let's Understand Ternary Operator syntax:- First\u00a0condition\u00a0is evaluated, then exactly one of\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/02\/Python-Ternary-Operator-conditional-expressions.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/02\/Python-Ternary-Operator-conditional-expressions.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/02\/Python-Ternary-Operator-conditional-expressions.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/02\/Python-Ternary-Operator-conditional-expressions.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/02\/Python-Ternary-Operator-conditional-expressions.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":33343,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-keywords-infographic\/","url_meta":{"origin":18926,"position":4},"title":"Python Keywords | Infographic","author":"Rohit","date":"October 3, 2022","format":false,"excerpt":"All Keywords in Python language. as as is used to create an alias while importing a module. It means giving a different name (user-defined) to a module while importing it. assert assert is used for debugging purposes break and continue break and continue are used inside for and while loops\u2026","rel":"","context":"In &quot;Info&quot;","block_context":{"text":"Info","link":"https:\/\/tutorial.eyehunts.com\/category\/info\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/10\/All-Keywords-in-Python-language.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/10\/All-Keywords-in-Python-language.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/10\/All-Keywords-in-Python-language.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/10\/All-Keywords-in-Python-language.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":16826,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-if-else-one-line-example-code\/","url_meta":{"origin":18926,"position":5},"title":"Python if else one line | Example code","author":"Rohit","date":"July 30, 2021","format":false,"excerpt":"Python if-else one line can be used as a ternary operator. There is the conditional expression. a if cond else b but this is an expression, not a statement. Example code if..else in a single line in Python In python need to convert the if\u2026else statement to a one-line conditional\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/07\/Python-if-else-one-line.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=18926"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18926\/revisions"}],"predecessor-version":[{"id":40950,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18926\/revisions\/40950"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=18926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=18926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=18926"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=18926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}