Re: [Tutor] some string operations

2008-10-04 Thread Kent Johnson
On Sat, Oct 4, 2008 at 4:03 AM, David <[EMAIL PROTECTED]> wrote: > Dear list, > > one of the exercises in Zelle's book is: > > given > > import string > s1 = "spam" > s2 = "ni!" > > show a Python expression that could construct the following result by > performing string operations on s1 and s2: N

Re: [Tutor] some string operations

2008-10-04 Thread Alan Gauld
"David" <[EMAIL PROTECTED]> wrote I have two solutions: a) (string.capitalize(s1) + " " + string.capitalize( s2) + " " ) * 3 b) "%s %s " % (string.capitalize(s1), string.capitalize(s2)) * 3 Both seem to work, but they seem overly complex. Where could I improve? Personally I'd go with b bu

Re: [Tutor] some string operations

2008-10-04 Thread Reed O'Brien
On Oct 4, 2008, at 4:03 AM, David wrote: Dear list, one of the exercises in Zelle's book is: given import string s1 = "spam" s2 = "ni!" show a Python expression that could construct the following result by performing string operations on s1 and s2: "Spam Ni! Spam Ni! Spam Ni!". I have t

[Tutor] some string operations

2008-10-04 Thread David
Dear list, one of the exercises in Zelle's book is: given import string s1 = "spam" s2 = "ni!" show a Python expression that could construct the following result by performing string operations on s1 and s2: "Spam Ni! Spam Ni! Spam Ni!". I have two solutions: a) (string.capitalize(s1) + "