On 2011-11-10 21:54, Cranky Frankie wrote:
What is the easiest way in Python 3.x to write output positionally? For example I have one literal I want in column 1, the next one in column 40, the third one in column 50. I've tried usings tabs and I'm not getting what I want. Is it something to do with C style printf formatting? An example would be greatly appreciated.
Two ideas: 1) Using string formatting: >>> print("x{0}x{1}x".format(" " * 38, " " * 9)) 2) Using a helper list (assuming screen width = 80): >>> line = [" "] * 80 >>> line[0] = "x" >>> line[39] = "x" >>> line[49] = "x" >>> print("".join(line)) Bye, Andreas _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor