{"id":38316,"date":"2016-10-25T19:02:38","date_gmt":"2016-10-26T00:02:38","guid":{"rendered":"http:\/\/edalitablog.wordpress.com\/?p=448"},"modified":"2016-10-25T19:02:38","modified_gmt":"2016-10-26T00:02:38","slug":"while-vs-for-in-python","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/while-vs-for-in-python\/","title":{"rendered":"While vs For in Python"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/edalitablog.wordpress.com\/2016\/10\/26\/while-vs-for-in-python\/\"><a href=\"https:\/\/edalitablog.wordpress.com\">Ed_Alita<\/a><\/a><\/em><br \/><\/p>\n<div class=\"X5GY7E6BwbZdXQ_CMZ_hG\"><a class=\"AcG-a0pLEWQMHV4-b3WUb\" href=\"http:\/\/giphy.com\/gifs\/quentin-tarantino-mortal-kombat-kill-bill-Qz2uFPTD6Mkik\"><img class=\"jOQ31oyCahmByl_HZ0hoR\" src=\"https:\/\/media4.giphy.com\/media\/Qz2uFPTD6Mkik\/200.gif#59\" width=\"564\" height=\"409\" \/><\/a><\/div>\n<div class=\"X5GY7E6BwbZdXQ_CMZ_hG\"><\/div>\n<h2 class=\"X5GY7E6BwbZdXQ_CMZ_hG\">The backgroud<\/h2>\n<p>This two funtions are used to create loop that inside is a code that you wish to repeat it self. The question is if they are the same how to choose between them. I will explain each one and then teach you how to choose between them.<\/p>\n<h2>For<\/h2>\n<p>This funtion repeats itself only the times that you indicate or until it condition is not longer true.<\/p>\n<p>Lets see this example:<\/p>\n<p><img class=\"alignnone size-full wp-image-457\" src=\"https:\/\/edalitablog.files.wordpress.com\/2016\/10\/for1.gif?w=748\" alt=\"for1\"   \/><\/p>\n<p>This code for each letter in the word Python will run the code.<\/p>\n<p>Let&#8217;s see what it does.<\/p>\n<p><img class=\"alignnone size-full wp-image-456\" src=\"https:\/\/edalitablog.files.wordpress.com\/2016\/10\/forex1.gif?w=748\" alt=\"forex1\"   \/><\/p>\n<h2>While<\/h2>\n<p>This funtion repeats itself until it make false it&#8217;s value.<\/p>\n<p>This is the logic that While follows:<\/p>\n<p><img class=\" size-full wp-image-466 aligncenter\" src=\"https:\/\/edalitablog.files.wordpress.com\/2016\/10\/while1.png?w=748\" alt=\"while1\" srcset=\"https:\/\/edalitablog.files.wordpress.com\/2016\/10\/while1.png 300w, https:\/\/edalitablog.files.wordpress.com\/2016\/10\/while1.png?w=150 150w\" sizes=\"(max-width: 300px) 100vw, 300px\"   \/><\/p>\n<p>The next Example will make it clear:<\/p>\n<p><img class=\"alignnone size-full wp-image-467\" src=\"https:\/\/edalitablog.files.wordpress.com\/2016\/10\/while2.gif?w=748\" alt=\"while2\"   \/><\/p>\n<p>This program will run each time until count be 9. Lets see what it does:<\/p>\n<p><img class=\"alignnone size-full wp-image-468\" src=\"https:\/\/edalitablog.files.wordpress.com\/2016\/10\/whileex1.gif?w=748\" alt=\"whileex1\"   \/><\/p>\n<h2><strong>Which one I use?<\/strong><\/h2>\n<p>The use of each one depends on what you need. Lets see if you know how many times the user will put the correct answer use for but if you don&#8217;t know how many times you can use a infinite while.<\/p>\n<p>The material use can be seen here:<\/p>\n<p><a href=\"https:\/\/docs.python.org\/3\/reference\/compound_stmts.html#while\" rel=\"nofollow\">https:\/\/docs.python.org\/3\/reference\/compound_stmts.html#while<\/a><\/p>\n<p>&nbsp;<\/p><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/edalitablog.wordpress.com\/448\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/edalitablog.wordpress.com\/448\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=edalitablog.wordpress.com&#038;blog=115122805&%23038;post=448&%23038;subd=edalitablog&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Ed_Alita The backgroud This two funtions are used to create loop that inside is a code that you wish to repeat it self. The question is if they are the same how to choose between them. I will explain each one and then teach you how to choose between them. For This &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/while-vs-for-in-python\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">While vs For in Python<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":457,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[78,24],"class_list":["post-38316","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-basic","tag-python"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=38316"}],"version-history":[{"count":6,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38316\/revisions"}],"predecessor-version":[{"id":42188,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38316\/revisions\/42188"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=38316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=38316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=38316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}