79131245

Date: 2024-10-27 18:41:57
Score: 0.5
Natty:
Report link

What you could do is to streamline your code by getting rid of match 1 and case 1 if and you should do the matching on the set itself plus and if guard within each case to compare the set like so:

def categorize_strings(string1, string2, string3):
    s = {string1, string2, string3}
    match s:
        case s if s == {' Hello', ' world', '!'}:
            return "Greeting"
        case s if s == {'beautiful', 'fair', 'nice'}:
            return "Compliments"
        case s if s == {'extremely', 'hyper', 'strongly'}:
            return "Adverbs"
        case _:
            return "Unknown"
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): What you
  • Low reputation (1):
Posted by: sori