• 0 Posts
  • 2 Comments
Joined 2 years ago
cake
Cake day: June 15th, 2023

help-circle

  • Functions in Python can only return a single value. While you are allowed to comma-separate additional values, as you have done, they are combined into a single tuple object that wraps the intended values.

    As such, your splitter function is returning a single tuple containing three strings. Your calculate function is expecting three individual arguments (I’m guessing that the error trace mentions this).

    To get around this, you can use the splat/asterisk operator to “unpack” the items from the tuple:

    a, b, c = splitter(expression)
    # or, inline
    calculate(*splitter(expression))
    

    Edit: removed bad asterisk