How to debug a Python loop-condition bug | Apple Interview Question