EPAM Systems Interview Question

Python code using loop of medium difficulty Pyspark code