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,196
  • 6
  • 41
  • 69

2 Answers2

4

Unpack using *:

test(*value(1,2)) # >>> test(1, 2)
Michael Bianconi
  • 4,942
  • 1
  • 8
  • 23
1

You need tuple unpacking:

test(*value(1,2))
ruohola
  • 19,113
  • 6
  • 51
  • 82