python - Can a list and variables be returned from a function? -
i can this..
def funcone():     a,b = functwo()     print a, b  def functwo():     .....     ......        return x, y   but can list returned functwo , displayed in funcone along 2 values? nothing seems work
when return multiple values, doing building single tuple containing values, , returning it. can construct tuples in it, , list comes under anything:
def funcone():     a, b, some_list = functwo()     print a, b, some_list  def functwo():     ...     some_list = [...]      return x, y, some_list   if mean wish return values list, can returning list, unpacking works lists too:
def funcone():     a, b, = functwo()     print a, b  def functwo():     ...     some_list = [x, y]      return some_list   or if want extend returned values values list, need concatenate list of values wish return list of values:
def funcone():     a, b, c, d = functwo()     print a, b, c, d  def functwo():     ...     some_list = [z, w]      return [x, y] + some_list      
Comments
Post a Comment