Loops/N plus one half: Difference between revisions

Line 256:
=={{header|Python}}==
<python>
myStringmyOutput = ""[]
for i in xrange(1, 11):
myString += strmyOutput.append(i)
if i == 10:
break
myString += myOutput.append(", ")
print myString''.join(myOutput)
</python>
 
Note: this example uses the Python idiom of building a string as a list and joining the parts together (on an empty string) which is generally far more efficient than instantiating new strings at every step along the way. (Strings are immutable so each expression using "some string" + "some other string" is building new objects rather than appending to existing ones).
 
=={{header|Scheme}}==
Anonymous user