I'm new in Python, today I was writing a simple test program on Python3.3 based on list. So, I've noticed that when I was entering tab space character \t
, the output was flashed such that I had enetered new line character! A sample is given below:
def printlist(list_name,tabs=0):
for items in list_name:
if isinstance(items,list):
printlist(items,tabs)
else:
print(items)
for num in range(tabs):
print('\t') #tab-stops provide
list3 = [
'list no. 3',
['tree','stems','root'],
['human','hand','leg'],
['robot','microprocessor','motor']
]
printlist(list3,1)
And the output is:
>>> ================================ RESTART ================================
>>>
list no. 3
tree
stems
root
human
hand
leg
robot
microprocessor
motor
>>>
But the output format what I intended is:
list no. 3
tree
stems
root
human
hand
leg
robot
microprocessor
motor
[I want tabs not a new line]
So how will it be possible?