MUFG interview question

Function to write string compression in python