This is a black box so maybe you can try to make up some test cases to debug your code.
Try to test your code with those strings (HELLOWORLD, HelloWorld, etc) in combination with the ascii art lines in the visible test cases. In particular, check whether your code handles "!" or any other non-alphabetical letters correctly. Also check that you haven't hardcoded any parameters unnecessarily.