Reputation: 75
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?
Upvotes: 0
Views: 158
Reputation: 154
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
* * * *
Upvotes: 2
Reputation: 23146
Fix the column widths:
print(f'{"Progress":<20} {"Trailer":<20} {"Retriver":<20} {"Excluded":<20}')
print(f'{"*":<20} {"*":<20} {"*":<20} {"*":<20}')
Progress Trailer Retriver Excluded
* * * *
If you would like to right-align instead, change the <20
to >20
Upvotes: 0