Aan de slagGa gratis aan de slag

Multi-line docstrings

Sometimes single-line docstrings are sufficient, but if your function is more complex or has several arguments, then it is generally a better choice to include a multi-line docstring.

You'll practice this by creating a multi-line docstring for the clean_text() function you made earlier.

Deze oefening maakt deel uit van de cursus

Intermediate Python for Developers

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

def clean_text(text, lower=True):
    # Add a multi-line docstring
    """
    ____
    
    """
    clean_text = text.replace(' ', '_')
    if lower == False:
        return clean_text
    else:
        return clean_text.lower()
Code bewerken en uitvoeren