[Tutor] string formatting problem

Bob Gailer bgailer@alum.rpi.edu
Sun Aug 3 11:48:02 EDT 2003


--=======44DBCF=======
Content-Type: text/plain; x-avg-checked=avg-ok-4A8548FE; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 10:22 AM 8/3/2003 -0400, Ron A wrote:

>I have this in a little program , and when it prints it goes to another
>line when it gets to the last part of the string.
>
>  print  "%s  PN  %s   %s   %0.2f" % (a, x, z[2], a*b)
>
>It prints like this.
>
>88   PN   1118   0.21
>    18.48
>
>I only have 4 spaces between each. Why would it split like this, and how
>do I fix it?


Here's what I get:

 >>> a=88
 >>> x=1118
 >>> b=0.20999999999999999
 >>> z=[0, 0,.21]
 >>> print  "%s  PN  %s   %s   %0.2f" % (a, x, z[2], a*b)
88  PN  1118   0.21   18.48

How is your program/data/environment different?

Bob Gailer
bgailer@alum.rpi.edu
303 442 2625

--=======44DBCF=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-4A8548FE
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003

--=======44DBCF=======--





More information about the Tutor mailing list