[Tutor] String Replacement Question
Moishy Gluck
moishyyehuda at gmail.com
Wed May 21 16:29:41 CEST 2008
On Wed, May 21, 2008 at 10:29 AM, Moishy Gluck <moishyyehuda at gmail.com>
wrote:
> >>> "%s " %st*3
> 'String String String '
> ^
> If you look closely at the end of the string there is an extra space.
>
> >>> " ".join((st, )*3)
> 'String String String'
> ^
> No extra space.
>
>
> On Wed, May 21, 2008 at 9:42 AM, Kinuthia Muchane <muchanek at gmail.com>
> wrote:
>
>> st = "String"
>>>>> print "%s " %st*3
>>>>>
>>>> String String String
>>
>>>
>>>>>
>> Does this help?
>>
>> Kinuthia...
>>
>> -----------------------------
>>
>> Message: 6
>> Date: Wed, 21 May 2008 15:05:21 +0530
>> From: Faheem <faheem at atlantiscomputing.com>
>> Subject: [Tutor] String Replacement question
>> To: tutor at python.org
>> Message-ID: <20080521150521.604437d8 at atlantiscomputing.com>
>> Content-Type: text/plain; charset=US-ASCII
>>
>> Hi all,
>> How do I replace the same value multiple times without repeating the
>> same variable name/value repeatedly?
>> for ex.
>>
>> some = 'thing'
>> print '%s %s %s %s' % (some,some,some,some)
>>
>> in this case, my question is how do i replace "% (some,some,some)" with
>> something more concise?
>>
>> thanks in advance,
>> Faheem
>>
>> _______________________________________________
>> Tutor maillist - Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080521/c486b262/attachment-0001.htm>
More information about the Tutor
mailing list