How to break a string across several lines but print as one line?
marklists at mceahern.com
Fri Aug 23 23:09:11 CEST 2002
> I have a very long string that I would like to be able
> to break across several lines. However, I need the
> string to print as one line. If I do something like
> foo = '''your momma is sooooo fat that she
> it prints as:
> your momma is sooooo fat that she
> I would like it as:
> your momma is sooooo fat that she fooballs.
The triple quote is designed for including newlines. So you need single
quotes and the \ as shown below:
Python 2.2.1 (#1, Jun 25 2002, 10:55:46)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "Your momma"
>>> s = "Your momma"\
... "is quite fat"\
... "and that's that."
"Your mommais quite fatand that's that."
More information about the Python-list