MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / to_simple_case

Function to_simple_case

strings/string_switch_case.py:27–41  ·  view source on GitHub ↗

>>> to_simple_case("one two 31235three4four") 'OneTwo31235three4four' >>> to_simple_case("This should be combined") 'ThisShouldBeCombined' >>> to_simple_case("The first letters are capitalized, then string is merged") 'TheFirstLettersAreCapitalizedThenStringIsMerged' >>>

(str_: str)

Source from the content-addressed store, hash-verified

25
26
27def to_simple_case(str_: str) -> str:
28 """
29 >>> to_simple_case("one two 31235three4four")
30 'OneTwo31235three4four'
31 >>> to_simple_case("This should be combined")
32 'ThisShouldBeCombined'
33 >>> to_simple_case("The first letters are capitalized, then string is merged")
34 'TheFirstLettersAreCapitalizedThenStringIsMerged'
35 >>> to_simple_case("special characters :, ', %, ^, $, are ignored")
36 'SpecialCharactersAreIgnored'
37 """
38 string_split = split_input(str_)
39 return "".join(
40 ["".join([char.capitalize() for char in sub_str]) for sub_str in string_split]
41 )
42
43
44def to_complex_case(text: str, upper: bool, separator: str) -> str:

Callers 2

to_pascal_caseFunction · 0.85
to_camel_caseFunction · 0.85

Calls 1

split_inputFunction · 0.85

Tested by

no test coverage detected