Convert snake_case to camelCase

Convert a snake_case string to camelCase.

IntermediateTopic: String Programs
Back

Python Convert snake_case to camelCase Program

This program helps you to learn the fundamental structure and syntax of Python programming.

Try This Code
# 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

Understanding Convert snake_case to camelCase

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

Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.

Table of Contents