Data Axle interview question

converting java code to python