Integrity errors

Could this just be a for-loop `for attempt in xrange(1, tries + 1):`, and then you can just check `if attempt == tries` in the `except` block below?