tuple to string/list

Peter Otten __peter__ at web.de
Fri Aug 22 09:42:07 CEST 2003


WIWA wrote:

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

Slightly off topic, here's a way to avoid the range(len(sequence)) idiom:

for m, t in zip(month, teller):
    f.write("Hits for %s: %s\n" % (m, t))

Peter




More information about the Python-list mailing list