I've started to learn Python with LPTHW and I've gotten to exercise 16:
http://learnpythonthehardway.org/book/ex16.html
And feel like an idiot because I can't figure out one of the seemingly simple "extra credit" assignments that wants the following:
target.write(line1)
target.write('
')
target.write(line2)
target.write('
')
target.write(line3)
target.write('
')
To be condensed to one line of code. I've tried some of the following:
target.write(line1
, line2
, line3
)
Or:
target.write('line1
, line2
, line3
')
Or:
target.write(%r
, %r
, %r
) % (line1, line2, line3)
I just can't get it to rewrite the line1, line2, and line3 strings all in the same line. And I've tried various other combinations with and without commas, quotes, etc. I keep getting varying errors, like Invalid Syntax or that I have too many arguments.
See Question&Answers more detail:os