Given a string in camel case, write a python program to convert the given string from camel case to snake case
SOLUTION CODE
from re import sub
def snake_case_funcion(s):
return '_'.join(
sub('([A-Z][a-z]+)', r' \1',
sub('([A-Z]+)', r' \1',
s.replace('-', ' '))).split()).lower()
camel_case_string = input("Enter a string in camel case: ")
print("The string in snake case is: ", snake_case_funcion(camel_case_string))
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment