Ask Your Question

List of variables as function arguments

asked 2020-06-25 13:03:48 +0200

ube gravatar image

I would like to define a function that takes a long list of variables as input and some complicated expression of my variables as my output, but I just don't seem to be able to make it work.

Something along the line of:

long_list_of_variables = [x_1, x_2,x_3]

But with much more variables.

I've tried different variations of this but I always seem to end up with the 'can't assign to function call'-error. Are there any way to achieve what I'm trying to do?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-28 03:18:15 +0200

Juanjo gravatar image

Just replace the last line of your code by

f = complicated_expression.function(*long_list_of_variables)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-06-25 13:03:48 +0200

Seen: 382 times

Last updated: Jun 28 '20