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?

kqw
  • 19,513
  • 11
  • 64
  • 96
Remi Guan
  • 20,142
  • 17
  • 60
  • 81

0 Answers0