Hitachi Rail interview question

Two Python questions involving string and array manipulation.