0
print(f'{"Progress":2} {"Trailer":3} {"Retriver":4} {"Excluded":5}')
print(f'{"*":2} {"*":3} {"*":4} {"*":5}')

The print function prints it as:

Progress Trailer Retriver Excluded
*  *   *    *

How can I align the star signs under the right column?

3
  • Does this answer your question? How can I change align columns vertically in python? Commented Nov 30, 2021 at 16:36
  • What did you expect {"Progress":2} to do? Commented Nov 30, 2021 at 16:51
  • I believe that the number after the string is the width including the text so just make sure that the width is bigger than the text length or it messes up Commented Nov 30, 2021 at 16:57

2 Answers 2

2

Try the below code, it will assign fixed column width and center the words:

print(f'{"Progress":^10} {"Trailer":^10} {"Retriver":^10} {"Excluded":^10}')
print(f'{"*":^10} {"*":^10} {"*":^10} {"*":^10}')

It will give output as below:

 Progress   Trailer    Retriver   Excluded 
    *          *          *          *     
Sign up to request clarification or add additional context in comments.

Comments

0

Fix the column widths:

print(f'{"Progress":<20} {"Trailer":<20} {"Retriver":<20} {"Excluded":<20}')
print(f'{"*":<20} {"*":<20} {"*":<20} {"*":<20}')
Output:
Progress             Trailer              Retriver             Excluded            
*                    *                    *                    *  

If you would like to right-align instead, change the <20 to >20

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.