Home > Software design >  Is There A Way to Insert Multiple Tabs in a Print Line
Is There A Way to Insert Multiple Tabs in a Print Line

Time:06-13

I've been web searching for this answer for a week or so and I'm not sure I'm either asking the right question or there is no way to do what I want, so here I am.

I understand that '\t' represents a single tab space in a line.

But is there a simpler way to represent say for example, three tabs, between words besides inserting '\t\t\t' in the print line?

I'm looking for something more eloquent, if possible. TIA. - Bruce

CodePudding user response:

In python, you can easily multiply a string by the repetition number to obtain a new string:

print("\t" * 3   "my text")
[output]:           my text

If you use this print multiple time, you can create your own print function:

def custom_print(value, *a**kwars):
    print("\t" * 3, value, *args, **kwars)

custom_print("text1", "text2")
[output]:            text1 text2
  • Related