Программа должна преобразовать "The_Cat-Was-pippi" в "TheCatWasPippi" и "the_stealth_warrior" в "theStealthWarrior" Но появляется ошибка:
File "/workspace/default/tests.py", line 5, in <module>
test.assert_equals(to_camel_case(''), '', "An empty string was provided but not returned")
File "/workspace/default/solution.py", line 3, in to_camel_case
if text[0].isupper():
IndexError: string index out of range ```
#Код
def to_camel_case(text):
text = text.replace('-', ' ').replace('_', ' ')
if text[0].isupper():
return text.title().replace(' ', '')
elif text=='':
return ""
else:
text = text.title().replace(' ', '')
return text.replace(text[0], text[0].lower(), 1)
print(to_camel_case('The_Cat-Was-pippi'))
print(to_camel_case('the_stealth_warrior'))
print(to_camel_case(''))
это должно уронить код :)