In the Python console, when I type:
>>> "\n".join(['I', 'would', 'expect', 'multiple', 'lines'])
Gives:
'I\nwould\nexpect\nmultiple\nlines'
Though I’d expect to see such an output:
I
would
expect
multiple
lines
What am I missing here?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The console is printing the representation, not the string itself.
If you prefix with
print, you’ll get what you expect.See this question for details about the difference between a string and the string’s representation. Super-simplified, the representation is what you’d type in source code to get that string.