python 2 lines in one 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 code in 1 line

exec("try: \n \t if sam[0] != 'harry': \n \t\t print('hello',  sam) \nexcept: pass")

Example 3: python how to write code over multiple lines

a = '1'   \
    + '2' \
    + '3' \
    - '4'