[Tutor] Noob question

Kent Johnson kent37 at tds.net
Tue Dec 11 13:19:28 CET 2007

Eric Brunson wrote:
> Hi Amit,
> This is fairly inefficient.  Because strings in python are immutable 
> this approach causes a new string to be created every iteration.

This is not true of CPython (the standard python.org release) since 
version 2.4:

Other versions of Python (Jython, IronPython, PyPy) do not have this 
optimization AFAIK.


> Amit Saxena wrote:
>> The simplest way i could think of:
>> a=["apple","orange","banana"]
>> b = ""
>> for i in range(len(a)):
>>      b += a[i]
>> print b

More information about the Tutor mailing list