def coerce_to_int(val, default=<NUM_LIT>):
try:<EOL><INDENT>return int(val)<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>if default != <NUM_LIT>:<EOL><INDENT>return default<EOL><DEDENT>return val<EOL><DEDENT>
Attempts to cast given value to an integer, return the original value if failed or the default if one provided.