for loop without variable

Neil Hodgson nyamatongwe+thunder at gmail.com
Fri Jan 11 17:18:22 EST 2008


Marty:

> I recently faced a similar issue doing something like this:
> 
>     data_out = []
>     for i in range(len(data_in)):
>         data_out.append([])

    Another way to write this is
data_out = [[]] * len(data_in)

    Neil



More information about the Python-list mailing list