Reputation: 319
I have a list of columns that I am trying to show as multiple columns:
Given below is the list:
for name in file:
worksheet.write(row, col, name)
col += 1
Given below is the output created:
['apples','oranges','bananas','pears']
I am trying to transpose it and have it displayed as below :
apples
oranges
bananas
pears
Could anyone advice how could I get my list transposed. Thanks
Upvotes: 0
Views: 160
Reputation: 3600
Changing the col increment to row increment will solve your problem.
for name in file:
worksheet.write(row, col, name)
row += 1
Output:
apples
oranges
bananas
pears
Upvotes: 0
Reputation: 71610
Use join
:
print('\n'.join(your_list))
join
can do what you want.
Output:
apples
oranges
bananas
pears
Upvotes: 0
Reputation: 848
If I'm getting it right you want this:
[list(item) for item in your_list]
This will create a 2d list, each item of which in it's own 'row'.
Upvotes: 1