In Python, How to define control structures if inside while loop?