How To Convert While Loop To For Loop In Python Using Range