tuple to string/list

Michael C. Neel neel at mediapulse.com
Thu Aug 21 21:51:06 CEST 2003


try this...

for i in range(len(month)):
    output="Hits for %s: %d" % (month[i],teller[i])
    f.write(str(output))
f.close()

didn't test, may have typos...

Mike

> -----Original Message-----
> From: WIWA [mailto:wim_wauters at skynet.be] 
> Sent: Thursday, August 21, 2003 3:41 PM
> To: python-list at python.org
> Subject: tuple to string/list
> 
> 
> Hi,
> 
> I'm a newbie learning to appreciate the strength of Python. I'm
> writing an application to look at the access_log of my apache server:
> 
> When I write:
> 
> for i in range(len(month)):
>     output="Hits for",month[i], ":" , teller[i]
>     f.write(str(output))
> f.close()
> 
> => this produces a tuple:
> ('Hits for', 'Jan', ':', 0)('Hits for', 'Feb', ':', 2)('Hits for',
> 'Mar', ':', 3)
> 
> => whereas I would like the following output:
> Hits for Jan: 0
> Hits for Feb: 2
> Hits for Mar: 3
> 
> Any easy way of obtaing this output?
> 
> Thanks in advance,
> 
> Wim
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 





More information about the Python-list mailing list