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

Function to_snake_case

strings/string_switch_case.py:101–108  ·  view source on GitHub ↗

>>> to_snake_case("one two 31235three4four", True) 'ONE_TWO_31235THREE4FOUR' >>> to_snake_case("one two 31235three4four", False) 'one_two_31235three4four'

(text: str, upper: bool)

Source from the content-addressed store, hash-verified

99
100
101def to_snake_case(text: str, upper: bool) -> str:
102 """
103 >>> to_snake_case("one two 31235three4four", True)
104 'ONE_TWO_31235THREE4FOUR'
105 >>> to_snake_case("one two 31235three4four", False)
106 'one_two_31235three4four'
107 """
108 return to_complex_case(text, upper, "_")
109
110
111def to_kebab_case(text: str, upper: bool) -> str:

Callers

nothing calls this directly

Calls 1

to_complex_caseFunction · 0.85

Tested by

no test coverage detected