Adding a keyword argument
Previously, you developed a custom function to clean text, as shown here:
# Create the clean_string function
def clean_string(text):
# Replace spaces with underscores
no_spaces = text.replace(" ", "_")
# Convert to lowercase
clean_text = no_spaces.lower()
# Display the final text as an output
return clean_text
Now, you will modify it to take different default keyword arguments!
This exercise is part of the course
Intermediate Python for Developers
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Define clean_text
____ ____(____, ____):
if lower == False:
clean_text = text.replace(" ", "_")
return clean_text
else:
clean_text = text.replace(" ", "_")
clean_text = clean_text.lower()
return clean_text