Infosys Interview Question

Write a program in python