Hitachi Rail Interview Question

Two Python questions involving string and array manipulation.