How to implement a while loop in Python?