0 votes
1 view
in Python by (47.8k points)

I have a long line of code that I want to break up among multiple lines. What do I use and what is the syntax?

For example, adding a bunch of strings,

e = 'a' + 'b' + 'c' + 'd'

and have it in two lines like this:

e = 'a' + 'b' + 

     'c' + 'd'

1 Answer

0 votes
by (107k points)

In the next line you can just have arguments without any problems:

An example that illustrates how you can write in the next line:

y = '1' + '2' + '3' + \

    '4' + '5'

Or:

x = ('1' + '2' + '3' + 

     '4' + '5')

The Python style guide says that using the implicit continuation with parentheses is preferred, but in this particular case just adding parentheses around your expression is probably the wrong way to go.

 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 2, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
asked Oct 4, 2019 in Python by Tech4ever (22.4k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...