w3resource logo
Python Exercises

Python: Convert snake case string to camel case string

Python Regular Expression: Exercise-37 with Solution

Write a python program to convert snake case string to camel case string.

Sample Solution:-

Python Code:

def snake_to_camel(word):
        import re
        return ''.join(x.capitalize() or '_' for x in word.split('_'))

print(snake_to_camel('python_exercises'))

Sample Output:

PythonExercises

Python Code Editor:

def snake_to_camel(word):
        import re
        return ''.join(x.capitalize() or '_' for x in word.split('_'))

print(snake_to_camel('python_exercises'))

Improve this sample solution and post your code through Disqus