Reputation: 13
I have a piece of Python code that looks something like this:
array1 = []
array2 = []
def my_function():
# do some stuff
return x, y # both are integers
# append x to array1; append y to array2
What I'm trying to do is append the outputs of my_function to separate arrays. I understand that I need to somehow separate my_function's 2 outputs and then make 2 separate append() statements, but I'm not quite sure how to implement that.
Thanks in advance!
Upvotes: 0
Views: 90
Reputation: 6729
x, y = my_function() #get x,y returned from my_function()
# append x to array1; append y to array2
array1.append(x)
array2.append(y)
Upvotes: 5