3

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) 
Iliass Mw
  • 57
  • 5
  • Does this answer your question? [How to split list and pass them as separate parameter?](https://stackoverflow.com/questions/6913084/how-to-split-list-and-pass-them-as-separate-parameter) – xskxzr Aug 09 '21 at 08:22

1 Answers1

9

You can use argument unpacking:

rgb_color(*black)
Aplet123
  • 33,825
  • 1
  • 29
  • 55