General Motors (GM) interview question

A small coding task on string in Python, nothing tricky.