A try-except-else might be more appropriate here.