{"id":38221,"date":"2016-10-24T08:22:58","date_gmt":"2016-10-24T13:22:58","guid":{"rendered":"http:\/\/firstprogrammingsteps.wordpress.com\/?p=305"},"modified":"2016-10-24T08:22:58","modified_gmt":"2016-10-24T13:22:58","slug":"for-loops-3","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/for-loops-3\/","title":{"rendered":"For Loops"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/firstprogrammingsteps.wordpress.com\/2016\/10\/24\/for-loops\/\"><a href=\"https:\/\/firstprogrammingsteps.wordpress.com\">Hackerman&amp;#039;s house<\/a><\/a><\/em><br \/><\/p>\n<p>&nbsp;<\/p>\n<p>I have already talked about while loops in a previous post, this time im gonna be talking about the for loops. A while loop executes the loop as long as a certain condition is accomplished, in the case of the for loop, it is used when we know the amount of times that we want something to happen.<\/p>\n<p>The syntax of this function is really simple.<\/p>\n<blockquote><p>list = [1, 3, 4, 5, 6, 7]<\/p>\n<p>for n in list:<\/p>\n<p>print(n)<\/p><\/blockquote>\n<p>We know that we want to repeat the loop with everything that is inside of the list this is one of the ways to use the for loop. If you don&#8217;t have a list of values you can also use the function range.<\/p>\n<blockquote><p>for x in range (2,15):<\/p>\n<p>print(x)<\/p><\/blockquote>\n<p>Really simple and really useful.<\/p>\n<div class=\"jetpack-video-wrapper\"><iframe class='youtube-player' type='text\/html' width='736' height='444' src='https:\/\/www.youtube.com\/embed\/xtXexPSfcZg?version=3&#038;rel=1&%23038;fs=1&%23038;autohide=2&%23038;showsearch=0&%23038;showinfo=1&%23038;iv_load_policy=1&%23038;wmode=transparent' allowfullscreen='true' style='border:0;'><\/iframe><\/div><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/firstprogrammingsteps.wordpress.com\/305\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/firstprogrammingsteps.wordpress.com\/305\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=firstprogrammingsteps.wordpress.com&#038;blog=115170367&%23038;post=305&%23038;subd=firstprogrammingsteps&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Hackerman&amp;#039;s house &nbsp; I have already talked about while loops in a previous post, this time im gonna be talking about the for loops. A while loop executes the loop as long as a certain condition is accomplished, in the case of the for loop, it is used when we know the &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/for-loops-3\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">For Loops<\/span><\/a><\/p>\n","protected":false},"author":59,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[24],"class_list":["post-38221","post","type-post","status-publish","format-standard","hentry","category-blogs","category-syndicated","tag-python"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38221","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\/59"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=38221"}],"version-history":[{"count":3,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38221\/revisions"}],"predecessor-version":[{"id":40707,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/38221\/revisions\/40707"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=38221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=38221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=38221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}