Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

write muli line conditional statements in python

# This is how multi-line statements are supposed to be
if (this_matches_condition, # or
    this_also_matches_condition
   ):# end of conditions
   get_something_done()
    
# I PREFER THIS WAY
if (
    sttmt1
    and (sttmt2 or sttmt3)
    or name == 'Goodman'
):
   something_happens ()

# This is also a good way
condition_list= (
    condition_one == 'number1'
    and condition_two == 'number2'
    and condition_three == 'number3'
)

if conditions_list:
    implement_something ()

else:
    something_else _is _done ()
 
PREVIOUS NEXT
Tagged: #write #muli #line #conditional #statements #python
ADD COMMENT
Topic
Name
7+2 =