Convert snake_case to camelCase

Convert a snake_case string to camelCase.

PythonIntermediate
Python
# Program to convert snake_case to camelCase

snake = input("Enter snake_case string: ")

parts = snake.split("_")

if not parts:
    camel = ""
else:
    camel = parts[0].lower() + "".join(word.capitalize() for word in parts[1:])

print("camelCase:", camel)

Output

Enter snake_case string: hello_world_example
camelCase: helloWorldExample

We split on underscores and capitalize each word after the first, then join them back.