Python Functions

Hello there, my name is @Code-Parser.

I have made a couple of clashes on CodinGame and come across some useful tools and functions is Python.

If you would like to read useful functions or add your own ideas or code-snippets, feel free to comment.


String Manipulation: snake_case

Here is a custom-code snippet for implementing snake_case in Python:

def snake_case(string):
    # Convert string to lowercase.
    string = string.lowercase()
    # Replace all spaces in string with underscores.
    string = string.replace(" ", "_")
    return string

Let’s try it out!

string = "This is a Sentence."


>> "this_is_a_sentence"

String Manipulation: Title Case

In Python, there is a built-in function for converting string to title case:

string = "This is a sentence."


>> "This Is A Sentence."

String Manipulation: camelCase

Let’s create a function that converts string into camelCase:

def camelCase(string):
    return ''.join(t.title() for t in s.split())

Let’s try it out:

string = "This is a sentence."


>> "thisIsASentence."

why not post these in here:
Learning materials


Will do very soon, thanks for your suggestion.

Hello @FoxLee, thanks for you comment. You may view the tutorial by clicking on this link:


Thanks again,

For all who come to this topic, you may search for playgrounds in the Community/Learn section of CodinGame. Thanks