try and except
Wrap risky code in a try block. If something inside raises an exception, control jumps to the matching except block instead of crashing the program. The except clause names which exception class to catch (or which classes, in a tuple).
A bare except: catches everything, including keyboard interrupts and system exits. Avoid it. If you do not know which exception to catch, catch Exception instead, which leaves the truly fatal ones alone.
The goal is not to suppress every error. The goal is to handle the specific cases you can recover from, and let the rest crash loudly so you can fix them.