tuple to string/list

Lyle Johnson lyle at users.sourceforge.net
Thu Aug 21 16:12:39 EDT 2003


WIWA wrote:

> 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?

     f.write( "Hits for %s: %d" % (month[i], teller[i]) )





More information about the Python-list mailing list