Get Error Type Python Function Example With A Loop