Convert while-loop into for-loop

Here we have a working while-loop. But, the same result can be achieved using a for-loop. Convert the while-loop into a for-loop.
Python
Setting up Python environment...
Output