-3

Is there a custom way of padding lines of text in python, I am using the escape characters "\t", but I wonder if there is an alternative. for example

print('My Name is:') print('Rambo') print('Mambo') 

Output:

.My Name is: .....Rambo ..Mambo 
1
  • write own print() and format as you like Commented Jun 28, 2017 at 5:25

2 Answers 2

1

Try using:

print('{:>15}'.format('My Name is:')) 

Refer for examples: PyFormat

Sign up to request clarification or add additional context in comments.

2 Comments

Seems to work, but does not work, the first print works, but the next prints are awful/
change the variable '15' according to your need.. don't expect this as an exact solution Its just an example ;)
0

Write a simple function for yourself.

def p(a,b): print(" "*a + b) p(1,"while") 

This should return:" while"

1 Comment

Ingenious.... never came to my find.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.