{"id":840,"date":"2022-08-30T15:08:03","date_gmt":"2022-08-30T15:08:03","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/increasing-the-value-of-a-for-loop-counter-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:08:03","modified_gmt":"2022-08-30T15:08:03","slug":"increasing-the-value-of-a-for-loop-counter-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/increasing-the-value-of-a-for-loop-counter-collection-of-common-programming-errors\/","title":{"rendered":"Increasing the value of a for loop counter-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<p>Variable, like in C<\/p>\n<p>In C, this loop leads to effectively making steps of 2, as obvious.<\/p>\n<\/li>\n<li>\n<p>Iterator, like in Python<\/p>\n<p>In Python, a loop like this gets fed by an iterator which constantly yields new values independent of the variable.<\/p>\n<pre><code>for i in range(0, 100):\n   print \"A:\", i\n   i += 1\n   print \"B:\", i\n<\/code><\/pre>\n<p>leads to<\/p>\n<pre><code>A: 0\nB: 1\nA: 1\nB: 2\n....\n<\/code><\/pre>\n<p>while your loop in C, provided with the correct outputs, would lead to<\/p>\n<pre><code>A: 0\nB: 1\nA: 2\nB: 3\n....\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:48:24. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Variable, like in C In C, this loop leads to effectively making steps of 2, as obvious. Iterator, like in Python In Python, a loop like this gets fed by an iterator which constantly yields new values independent of the variable. for i in range(0, 100): print &#8220;A:&#8221;, i i += 1 print &#8220;B:&#8221;, i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-840","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=840"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/840\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}