4

I have a function that I can not edit, this function expects 3 arguments

def rgb_color(r,g,b):
    print(r,g,b)

now I have these values as an array, I can change this var if needed to a list or something

black = [0, 0, 0]

Is there a way to pass the variable black to the function without using

black[0], black[1], black[2]

something like

call_user_function(rgb_color, black) 
1

1 Answer 1

10

You can use argument unpacking:

rgb_color(*black)
Sign up to request clarification or add additional context in comments.

1 Comment

I wish this were easier to find

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.