Infosys Interview Question

it was a python Coding question