Reputation: 27
I have 2 different arrays and I need help printing both of them
Route = ["Bus A","Bus B","Bus C","Bus D","Bus E","Bus F"]
DaysLate = [ [1],[2],[3],[4],[5],[6] ]
is there a way I can get this output?
Bus A 1
Bus B 2
Bus C 3
Bus D 4
Bus E 5
Bus F 6
Upvotes: 1
Views: 68
Reputation: 17794
You can also use the function chain.from_iterable()
from itertools
module to chain all sublists into a single sequence:
for i, j in zip(Route, itertools.chain.from_iterable(DaysLate)):
print(i, j)
Alternatively you can use a star *
to unpack sublists:
for i, j in zip(Route, DaysLate):
print(i, *j)
Upvotes: 0
Reputation: 11073
Try this:
Route = ["Bus A","Bus B","Bus C","Bus D","Bus E","Bus F"]
DaysLate = [ [1],[2],[3],[4],[5],[6] ]
for i,j in zip(Route,DaysLate):
print(i, j[0])
Upvotes: 2