Block interview question

Python easy problem about strings (does not translate well to R)