← Back to challenges

Convert String to camelCase

PythonHardstringsformattingregex

Instructions

Create a function that converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized.

Examples

to_camel_case("A-B-C") ➞ "ABC"

to_camel_case("the-stealth-warrior") ➞ "theStealthWarrior"

to_camel_case("The_Stealth_Warrior") ➞ "TheStealthWarrior"

Notes

An empty string as input "" should return an empty string.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.