Loops/For with a specified step: Difference between revisions

added php, python3
(Logo)
(added php, python3)
Line 31:
for [i 2 8 2] [type :i type "|, |] print [who do we appreciate?]
</lang>
 
=={{header|PHP}}==
<lang php><?php
foreach (range(2, 8, 2) as $i)
echo "$i, ";
echo "who do we appreciate?\n";
?></lang>
Output
<pre>2, 4, 6, 8, who do we appreciate?</pre>
 
=={{header|Python}}==
{{works with|Python|2.x}}
<lang python>for i in range(2, 9, 2):
<lang python>for i in xrange(2, 9, 2):
print "%d," % i,
print "who do we appreciate?"</lang>
{{works with|Python|3.x}}
<lang python>for i in range(2, 9, 2):
print("%d, " % i, end="")
print("who do we appreciate?")</lang>
Output
<pre>2, 4, 6, 8, who do we appreciate?</pre>
Anonymous user