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.
Thanks,
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."
print(snake_case(string))
>> "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."
print(string.title())
>> "This Is A Sentence."
1 Like
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."
print(camelCase(string))
>> "thisIsASentence."
1 Like
FoxLee
#5
why not post these in here:
Learning materials
2 Likes
Will do very soon, thanks for your suggestion.
Hello @FoxLee, thanks for you comment. You may view the tutorial by clicking on this link:
or
Thanks again,
Code-Parser
For all who come to this topic, you may search for playgrounds in the Community/Learn section of CodinGame. Thanks