Seems to be working just have to convert to codingbat format
Will work this way but also can be a one liner
One liner
Codingbat's even shorter solution