def _lower ( string ) : if not string : return "" new_string = [ string [ 0 ] . lower ( ) ] for char in string [ 1 : ] : if char . isupper ( ) : new_string . append ( "_" ) new_string . append ( char . lower ( ) ) return "" . join ( new_string )
python extend the same list in lower case
Custom lower string function . Examples : FooBar - > foo_bar
def _lower(string):
    """Custom lower string function.
    Examples:
        FooBar -> foo_bar
    """
    if not string:
        return ""

    new_string = [string[0].lower()]
    for char in string[1:]:
        if char.isupper():
            new_string.append("_")
        new_string.append(char.lower())

    return "".join(new_string)