[Tutor] List indexing problem

Kent Johnson kent37 at tds.net
Sat Jul 26 09:08:45 CEST 2008

On Fri, Jul 25, 2008 at 7:35 PM, Mike Meisner <mikem at blazenetme.net> wrote:
> Do you happen to know if there is an efficient way to initialize a  list
> like this without explicitly writing out each element?

You can make a copy of the inner list each time through the loop:
    IP = []
    temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
    # initialize to zero
    for i in range(20):


More information about the Tutor mailing list