Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

Just like C, you can break a long line into multiple short lines. But in Python, if I do this, there will be an indent error... Is it possible?

closed

1 Answer

0 votes
by (106k points)
selected by
 
Best answer

Yes, It is possible to break a long line to multiple lines in Python. The preferred way is by using Python's implied line continuation inside parentheses, brackets and braces.

You can add an extra pair of parentheses around an expression if it is necessary, but sometimes using a backslash looks better. Also, make sure to indent the continued line appropriately.

An example that illustrates how to do implicit line continuation:

a = some_function(

    '1' + '2' + '3' - '4')

 watch this YouTube tutorial on Python:

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers

500 comments

108k users

Browse Categories

...