1

I am trying to print something out in the console and want to make sure it is aligned properly. What I am getting is:

enter image description here

But what I want is for the Location.... to be all aligned. Not sure how to fix this. My code is:

print("{:>7}{:>60}".format(date, longitude))

1 Answer 1

2

Your format string specifies a minimum width of 7 characters for date, but strings like "Sunday 14 December 2014 at 09.53 PM" are far longer and appear with their natural length. Replace 7 with an appropriate large number (at least the maximum possible length of the date string) to obtain the padding you want.

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

1 Comment

Thanks I just figured it out, but will keep it up for some other person new to python. Thanks.

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.