Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Conversion from CamelCase by book1978
def from_camel_case(name: str) -> str:
s = name[:1].lower()
for i in name[1:]:
if i.isupper():
s += '_' + i.lower()
else:
s += i
return s
print("Example:")
print(from_camel_case("MyFunctionName"))
# These "asserts" are used for self-checking
assert from_camel_case("MyFunctionName") == "my_function_name"
assert from_camel_case("IPhone") == "i_phone"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Feb. 15, 2024
Comments: