Reputation: 14709
I have looked this up and can't seem to figure out why it's happening.
print "Percentage of A\tB\tC\tD"
#prints: Percentage of A B C D
However,
print "Percentage of A\tB\tC\tD"
#prints: Percentage of A B C D
Two questions:
of
and A
make a difference?Upvotes: 0
Views: 47
Reputation: 199
Alternatively, you could use string formatting and specify the width of each field (e.g. {0:8} {1:8} etc)
Upvotes: 4
Reputation: 1125068
How tabs are handled depends on the terminal or console. Often, they indent to specific tab stops; predefined columns regardless of where the tab was printed.
E.g. if there are tab stops every 8 spaces, printing a tab at column 12 means the cursor skips to column 16, and does not skip 8 spaces to column 20.
With the addition of a space you made the tab fill out to the next tab stop at position 24:
>>> len('Percentage of A')
15
>>> len('Percentage of A')
16
Upvotes: 2