IBM interview question

coding question in python for the OA