Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (47.6k 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 (106k points)
edited by

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.

Learn more about Python from an expert. Enroll in our Python Course!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 2, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Oct 4, 2019 in Python by Tech4ever (20.3k points)

Browse Categories

...