You can download this code by clicking the button below.
This code is now available for download.
This function converts the input text to different string formats based on the specified format type, such as uppercase, lowercase, title case, etc.
Technology Stack : String (str)
Code Type : String formatting function
Code Difficulty : Intermediate
def string_formatting(text, format_type):
if format_type == 'upper':
return text.upper()
elif format_type == 'lower':
return text.lower()
elif format_type == 'title':
return text.title()
elif format_type == 'capitalize':
return text.capitalize()
else:
return "Unknown format type"