mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Added doctest to string_switch_case.py (#11136)
* Added doctest to string_switch_case.py * Update string_switch_case.py
This commit is contained in:
parent
fa508d7b8b
commit
12e401650c
|
@ -28,6 +28,12 @@ def to_simple_case(str_: str) -> str:
|
|||
"""
|
||||
>>> 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'
|
||||
>>> to_simple_case("special characters :, ', %, ^, $, are ignored")
|
||||
'SpecialCharactersAreIgnored'
|
||||
"""
|
||||
string_split = split_input(str_)
|
||||
return "".join(
|
||||
|
@ -37,6 +43,14 @@ def to_simple_case(str_: str) -> str:
|
|||
|
||||
def to_complex_case(text: str, upper: bool, separator: str) -> str:
|
||||
"""
|
||||
Returns the string concatenated with the delimiter we provide.
|
||||
|
||||
Parameters:
|
||||
@text: The string on which we want to perform operation
|
||||
@upper: Boolean value to determine whether we want capitalized result or not
|
||||
@separator: The delimiter with which we want to concatenate words
|
||||
|
||||
Examples:
|
||||
>>> to_complex_case("one two 31235three4four", True, "_")
|
||||
'ONE_TWO_31235THREE4FOUR'
|
||||
>>> to_complex_case("one two 31235three4four", False, "-")
|
||||
|
|
Loading…
Reference in New Issue
Block a user