SoulJam SoulJam - 6 months ago 21
Python Question

Python list print tabulation

I want to print tabulated list, but I can't tabulate first member of list.

list = ['data', 'data','data']
print(*list, sep='\n \t')


But I get:

data

----data

----data

I would like to get:

----data

----data

----data

How to tabulate first member?

Answer

Did you mean this,

l = ['data', 'data','data']

s = '\n'.join(['----'+item for item in l])
print(s)
# Ouput
----data
----data
----data