Given a string in camel case,write a program to convert the given string from camel case to snake case...
example:
if the given word is "PythonLearning" in camel case.,your code should print given word in snake case "Python_Learning"...
def cameltosanke(str):
res = [str[0]]
for c in str[1:]:
if c in ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
res.append('_')
res.append(c)
else:
res.append(c)
return ''.join(res)
str = input()
print(cameltosanke(str))
Comments
Leave a comment