Write code to convert user input to an integer if possible, handling negative inputs without using string.ToInt().
Implement parse_integer(user_input) for a string containing an optional sign and decimal digits. Ignore leading and trailing whitespace, return the parsed integer for valid input, and return None for invalid input. Do not use int(), string.ToInt(), or another built-in numeric conversion method.
Signature: parse_integer(user_input)
+ or - followed by one or more ASCII decimal digitsNone for empty, sign-only, or otherwise invalid inputint(), string.ToInt(), or another built-in numeric conversiondef parse_integer(user_input):