Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions stringcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ def camelcase(string):
string: Camel case string.

"""

if string == "":
return string

string = string.replace("_","-")
lst = string.split("-")
for i in range(len(lst)):
if i == 0:
continue
else:
lst[i] = lst[i].capitalize()

return "".join(lst)
snake = snakecase(string)
if not snake:
return snake

words = [word for word in snake.split("_") if word]
if not words:
return ''

head, *tail = words
return head + ''.join(word.capitalize() for word in tail)

def capitalcase(string):
"""Convert string into capital case.
Expand Down