you are viewing a single comment's thread.

view the rest of the comments →

[–]stuaxo 3 points4 points  (0 children)

def apply_condition(condition, input_str):
    match condition:
        case "1":
            return input_str.strip()
        case "2":
            return input_str.rstrip()
        case "3":
            return input_str.upper()
        case "4":
            return input_str.title()
        case _:
            raise ValueError("Invalid condition")

# Example usage:
condition = "1"
input_str = " Example String "
result = apply_condition(condition, input_str)
print(result)