[Tutor] Are there other ways of solving this exercise?
Walter Prins
wprins at gmail.com
Thu Jan 12 15:40:26 CET 2012
Hi,
On 12 January 2012 14:24, amt <0101amt at gmail.com> wrote:
>
> target.write("%s\n%s\n%s\n" %(line1, line2, line3))
>
> This is the only method I was able to figure out of solving the exercise.
>
> Are there other ways of solving this exercise using strings, formats
> and escapes like the author mentioned in the exercise question? If
> yes, please write them.
Firstly for those interested, I've tracked this down to "Learn Python
The Hard Way, 2nd Edition". (Amt, please include a reference if
possible (especially when online) when you ask questions.) The
question is available here:
http://learnpythonthehardway.org/book/ex16.html
As for your question, I suppose using the string.format() method is
another way that involves "strings, formats and escapes". See here:
http://docs.python.org/library/stdtypes.html (and see the section on
str.format therein. )
Walter
More information about the Tutor
mailing list