0

I have some text and I want concatenate them, but they're too long. So I can do this:

b = 'Hello\n'\
    'Hi\n'\
    'This is a test'

print(b)

Output:

Hello
Hi
This is a test

But today I find a new way to do this, and this way is more clearer. Like this:

a = ('Hello\n'
     'Hi\n'
     'This is a test')

print(a)

Output:

Hello
Hi
This is a test

So now my question is: How does it work? Why does it wouldn't create a tuple or raise a SyntaxError?

the
  • 21,007
  • 11
  • 68
  • 101
Remi Guan
  • 21,506
  • 17
  • 64
  • 87

0 Answers0