Skip to content

Added doctest to string_switch_case.py #11136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions strings/string_switch_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

'SpecialCharactersAreIgnored'
"""
string_split = split_input(str_)
return "".join(
Expand All @@ -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, "-")
Expand Down