EPAM Systems interview question

Working code for simple python question is expected