d" % n. Given all those calculations are done and in a list of (char, num): Thanks for contributing an answer to Stack Overflow! But avoid … To learn more, see our tips on writing great answers. Required, but never shown Required, but never shown 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. Explore related questions See similar questions with these tags. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2025.8.6.32596" /> d" % n. Given all those calculations are done and in a list of (char, num): Thanks for contributing an answer to Stack Overflow! But avoid … To learn more, see our tips on writing great answers. Required, but never shown Required, but never shown 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. Explore related questions See similar questions with these tags. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2025.8.6.32596" />

python - How to right-align numeric data? - Stack Overflow

Communities for your favorite technologies. Explore all Collectives Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Find centralized, trusted content and collaborate around the technologies you use most. Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. I have some data that I am displaying in 3 column format, of the form: key: value key: key: value key: value. Here's an example: However, I'd like if the numbers were all right aligned, such as: How can I do this in Python? Here is the existing printing code I have: In python 2.6+ (and it's the standard method in 3), the "preferred" method for string formatting is to use string.format() (the complete docs for which can be found here). right justification can be done with this will use 5 places, however is also valid and will use the value width as passed to .format(). In Python 2.5 use rjust (on strings). Also, try to get used to string formatting in python instead of just concatenating strings. Simple example for rjust and string formatting below: Use python string formatting: '%widths' where width is an integer In Python 3.6 you can use Literal String Interpolation, which is less verbose and probably more intuitive to use: Or just: It reuses much of the str.format() syntax. I guess/hope this will be the prefered way in the future. If you know aa upper bound for your numbers, you can format with "%d" % n. Given all those calculations are done and in a list of (char, num): Thanks for contributing an answer to Stack Overflow! But avoid … To learn more, see our tips on writing great answers. Required, but never shown Required, but never shown 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. Explore related questions See similar questions with these tags. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2025.8.6.32596

Rp.10.000
Rp.100.000-90%
Kuantitas