python if in multiple lines code example

Example 1: python if statement multiple lines

# ex. 1
if (cond1 == 'val1' and cond2 == 'val2' and 
       cond3 == 'val3' and cond4 == 'val4'):
    do_something
    
# Also, don't forget the whitespace is more flexible than you might think:
# ex. 2
if (   
       cond1 == 'val1' and cond2 == 'val2' and 
       cond3 == 'val3' and cond4 == 'val4'
   ):
    do_something
if    (cond1 == 'val1' and cond2 == 'val2' and 
       cond3 == 'val3' and cond4 == 'val4'):
    do_something

Example 2: python make return on multiple lines

# Python return on multiple lines with '()'
# Instead of:
return <something to return> + <something else to return>
# Use:
return (<something to return> +
        <something else to return>)