Convert snake_case to camelCase in Python
Convert a snake_case string to camelCase.
IntermediateString ProgramsExample 25 of 25
convert-snake-case-to-camelcase.py
Run in browser1# Program to convert snake_case to camelCase23snake = input("Enter snake_case string: ")45parts = snake.split("_")67if not parts:8 camel = ""9else:10 camel = parts[0].lower() + "".join(word.capitalize() for word in parts[1:])1112print("camelCase:", camel)
Output
Enter snake_case string: hello_world_example camelCase: helloWorldExample
What's going on
We split on underscores and capitalize each word after the first, then join them back.