While Loop Functional Programming In Python