Reputation: 71
Why do I see output only if I put space.
print "I love you %s" % "\tI'm tabbled in."
print "I love you %s" % " \tI'm tabbled in."
output
I love you I'm tabbled in.
I love you I'm tabbled in.
Upvotes: 6
Views: 100
Reputation: 61975
Typically, \t (TAB) goes to the next tab stop - it is not a synonym for "n spaces".
I love you XI'm tabbled in.
I love you XXXXI'm tabbled in.
0---1---2---3---4---
The current terminal is configured with a tab stop size of 4 which is shown on the bottom. The "X" are the characters skipped by the tab.
So the first line skips one character with the tab (it goes to tab stop #3) and the second line writes a space and then skips four characters (to get to tab stop #4).
Upvotes: 12