Published on January 26, 2024By DeveloperBreeze

# Decorator function to uppercase the result of another function
def uppercase_decorator(function):
    def wrapper(*args, **kwargs):
        result = function(*args, **kwargs)
        return result.upper()
    return wrapper

# Function decorated with the uppercase_decorator
@uppercase_decorator
def greet(name):
    return f'Hello, {name}'

# Usage: Call the decorated function
result = greet('Alice')

Comments

Please log in to leave a comment.

Continue Reading:

JavaScript Prime Number Check

Published on January 26, 2024

javascript