• 4 Posts
  • 10 Comments
Joined 2 years ago
cake
Cake day: July 7th, 2023

help-circle
  • Functions in Python can only return a single value

    that’s not true accurate, this is valid code in this context:

    x, y, z = splitter(expression)
    

    Where x, y, and z are strings. But when you do this, akin to what OP did:

    value  = splitter(expression)
    

    then value is a tuple of 3 strings.

    In fact, unpacking with asterisk at assignment, like below, is not allowed:

    x, y, z = *splitter(expression)
    
        x, y, z = *splitter(expression)
                  ^^^^^^^^^^^^^^^^^^^^^
    SyntaxError: can't use starred expression here