[Tutor] Re: string formatting problem

Alan Gauld alan.gauld@blueyonder.co.uk
Sun Aug 3 13:10:02 EDT 2003


> def invoice(): 
>             y = data.readline() 
>             z = string.split(y, ',') 
>   print  "%s  PN  %s   %s   %0.2f" % (a, x, z[2], a*b) 

Ah, now z is a line split, How long is Z[2]? Does it have a 
lot of whitespace at the end? Try inserting a debugging 
statement:

print len(z[2])

You may need to use strip to get rid of excess spaces etc...

Alan G.





More information about the Tutor mailing list