IBM Interview Question

coding question in python for the OA