Hi people of Stackoverflow,
I have a function which calculates a list and I want to return each element of the list individually, like so (the function receiving this return is designed to handle an undefined number of parameters):
def foo():
my_list = [1,2,3,4]
return 1,2,3,4
The number of elements in the list is undefined so I can't do:
return my_list[0], my_list[1], ...
I think there must be an easy solution to this but I can't seem to wrap my head around it. Any suggestions? Thanks!
EDIT: Thanks for your answers, so here is the extension to my problem, which is really my problem:
def foo():
my_list = [1,2,3,4]
return "any_other_value", my_list
So, what I want is that when I call foo()
, bar = foo()
, bar[0] = "any_other_value", bar[1] = 1, bar[2]=3, bar[3] = 4
. And my_list
is of undetermined length (here it has only 4 elements).