Infosys interview question

Write a program in python