Skip to content

Latest commit

 

History

History
52 lines (29 loc) · 731 Bytes

CamelCase_Method.md

File metadata and controls

52 lines (29 loc) · 731 Bytes

CodeWars Python Solutions


CamelCase Method

Write simple .camelCase method (camel_case function in PHP, CamelCase in C# or camelCase in Java) for strings. All words must have their first letter capitalized without spaces.

For instance:

camelcase("hello case") => HelloCase
camelcase("camel case word") => CamelCaseWord

Given Code

def camel_case(string):
    pass

Solution 1

def camel_case(string):
    return "".join([w.title() for w in string.split()])

Solution 2

def camel_case(string):
    return string.title().replace(" ", "")

See on CodeWars.com