[Tutor] ASCII art generator - tuple and writelines

Michael Janssen Janssen@rz.uni-frankfurt.de
Sun Feb 2 12:53:02 2003


On Sun, 2 Feb 2003, Michael Miller wrote:

> > "out" should be a string not a tuple. The html-file becomes cleaner.
>
> You lost me there. The HTML ends up as <FONT color="#70747D">#</FONT>, which
> is just fine as far as HTML goes. To show my stupidity a bit more, I thought
> it already was a string...

you're right, I was wrong. I've always thought writelines adds newlines in
case they arn't allready there. But it doesn't. Therefore out as tuple is
written to one line.

To make it a string change:
out = '<FONT color="','#%02X%02X%02X'%(r,g,b),'">'+makerand(),'</FONT>\n'
to:
out = '<FONT color="'+'#%02X%02X%02X'%(r,g,b)+'">'+makerand()+'</FONT>\n'

and myfile.writelines(out) to myfile.write(out).

Michael 2