Write a single line of code divided into multiple lines

Asked 1 years ago, Updated 1 years ago, 48 views

It's hard to see because I'm trying to write a very long code in one line. Can you divide a line of code into several lines?

For example, e = 'a' + 'b' + 'c' + 'd'

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

How to make it together.

python syntax

2022-09-21 17:55

1 Answers

In normal cases, you can write backslash \ or parentheses ().

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

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

if a == True and \
    b == False :
    ...

If you're just passing the parameter, you can use it as follows

myfunc(param1, param2,
param3, param4,
param5, param6)

However, if statements do not support the method of writing parentheses For if, you can only write \.

See python style guide - maximum line length


2022-09-21 17:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.