0

I am trying to simplify the problem, the simple code is below. how can I pass two/any arguments(which comes from another function return value) to the test method? Is it possible, or we can't do it in python?

def values(x, y):
    return (x,y)

def test(x, y):
    print(x,y)

# error at below 
test(value(1,2))
ajayramesh
  • 3,576
  • 8
  • 50
  • 75

2 Answers2

4

Unpack using *:

test(*value(1,2)) # >>> test(1, 2)
Michael Bianconi
  • 5,072
  • 1
  • 10
  • 25
1

You need tuple unpacking:

test(*value(1,2))
ruohola
  • 21,987
  • 6
  • 62
  • 97