Camelcase in Python
What Does Camelcase Mean?
Camelcase is a naming protocol for giving file or attribute names that contain more than one word joined that all start with a capital letter. Camelcase is a programming language that allows you to name files or functions without breaking the underlying language's naming rules.
The name camelcase comes from its look, which resembles the back of a camel. Many programming languages that do not allow space in file names use it. Camelcase allows developers to create more distinctive and meaningful titles for them.
HelloWorld, Helloworld, and helloWorld, for example, are considerably easier to read than helloworld.
Ways to Convert String in Camelcase
These are the steps we'll take to solve it. Make a blank string first. Then we'll make the initial letter of each word in the string uppercase and the rest lowercase, and afterward, concatenate the words with s. Then, by lowering the initial letter, return the final string.
Using re Module
In this, we will use sub of the re module
original s1: Python javatpoint camelCase of s1: pythonJavatpoint original s2: Python,javatpoint camelCase of s2: python,Javatpoint original s3: Python_javatpoint camelCase of s3: pythonJavatpoint original s4: python_javatpoint.tutorial-camelcase camelCase of s3: pythonJavatpoint.TutorialCamelcase
By Using split(), join(), title() and Generator Expression
This problem can be solved using a mix of the preceding functions. We divide all underscores initially; next, we will append the first word to the final string. We will proceed by title-cased words using the generator expression i.e. a for loop and title() function.
The original string is : javatpoint_is_best_for_coding_tutorials The camelcase of the string created is : javatpointIsBestForCodingTutorials
By Using split(), join(), title() and map()
This problem can be solved using a mix of the preceding functions. Using map(), we accomplish the goal of applying logic to full strings.
The original string is : javatpoint_is_best_for_coding_tutorials The camelcase of the created string is : javatpointIsBestForCodingTutorials
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week