← Back to challenges

camelCase ⇄ snake_case

PythonHardalgorithmsregexformattingstrings

Instructions

Create two functions to_camel_case() and to_snake_case() that each take a single string and convert it into either camelCase or snake_case.

Examples

to_camel_case("hello_innokodakademija") ➞ "helloInnokodakademija"

to_snake_case("helloInnokodakademija") ➞ "hello_innokodakademija"

to_camel_case("is_modal_open") ➞ "isModalOpen"

to_snake_case("getColor") ➞ "get_color"

Notes

Test input will always be appropriately formatted as either camelCase or snake_case, depending on the function being called.

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