Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #'the-stealth-warrior' gets converted to "theStealthWarrior"
- #'the_stealth_warrior' gets converted to "theStealthWarrior"
- def camel_to_case(text):
- #a list for initially store data
- txt=[]
- #create an empty string to store the final list arrays
- camel_text=''
- start=0
- for i, pointer in enumerate(text):
- if pointer=='_' or pointer=='-':
- txt.append(text[start:i])
- start=i+1
- if len(text)>start:
- txt.append(text[start:])
- for i, txt in enumerate(txt):
- if i == 0: #first character remain same as the input
- camel_text += txt
- else:
- camel_text+=txt.capitalize()
- return camel_text
- print(camel_to_case(input(""))
- # input as ( To-Test_prb_math-phy_botany-_start)
- # it returns (ToTestPrbMathPhyBotanyStart)
Add Comment
Please, Sign In to add comment