-1

I am trying to make my script a bit neater, but I have loads of print "str" statements that are really long.

So I might have:

print("Hello, welcome to blah blah blah blah blah blah blah blah blah blah")

However, ideally I'd like this to continue onto a new line, rather than have it trail across the length of the Editor.

It's not hugely important I don't think, but is it possible?

Anonypy
  • 73
  • 1
  • 7
  • 2
    Possible duplicate of [How to declare a long string in Python?](http://stackoverflow.com/questions/8577027/how-to-declare-a-long-string-in-python) – fredtantini Nov 22 '16 at 13:06

2 Answers2

0

In Python, there are numerous possibilities to do this, one is to use """ or alternatively ''' like this:

very_long_string="""Hello,
welcome to 
blah blah blah blah
blah blah blah blah
blah blah"""

You can read more on multi-line strings here.

thatguy
  • 21,059
  • 6
  • 30
  • 40
0

You can do that using the triple quotes. Triple quotes in python preserve the formatting of the text that has to be printed. So you can put the string to be printed in like this (if you want it to be like this):

print '''Hello, welcome to
Hello, welcome to blah blah blah
blah blah blah blah blah'''