def str_to_bool(string):
 if (string is not None):
  if (string.lower() in ['true', 'yes', '1', 'on']):
   return True
  elif (string.lower() in ['false', 'no', '0', 'off']):
   return False
 return None

def str_to_bool ( string ) : if ( string is not None ) : if ( string . lower ( ) in [ 'true' , 'yes' , '1' , 'on' ] ) : return True elif ( string . lower ( ) in [ 'false' , 'no' , '0' , 'off' ] ) : return False return None
given a string .