I have 3 arrays, a1, a2, a3
I would like to return all three of them at once.
I have
return a1, a2, a3
but it returns them all on the same line, I was wondering how I would return them each on a new line
Do you mean like this?
>>> def f():
... a1 = [1, 2, 3]
... a2 = [4, 5, 6]
... a3 = [7, 8, 9]
... return a1, a2, a3
...
>>> f()
([1, 2, 3], [4, 5, 6], [7, 8, 9])
You can unpack the return value like this
>>> b1, b2, b3 = f()
>>> b1
[1, 2, 3]
>>> b2
[4, 5, 6]
>>> b3
[7, 8, 9]
Or print it on 3 lines like this
>>> print "\n".join(str(x) for x in f())
[1, 2, 3]
[4, 5, 6]
[7, 8, 9]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With