Loop in list.

Caleb Hattingh caleb1 at telkomsa.net
Tue Feb 8 23:47:36 EST 2005


Stephen

You're gonna have to help me here.....what is the effective difference?

Thanks
Caleb

>> '>>> a = []
>> '>>> for b in range(4):
>> '>>>     for i in range(3):
>> '>>>         a.append(i*2*b)
>
> There is a subtle error in this explanation. The equivilence actually
> looks like:
>
> '> a = []
> '> l1 = range(4)
> '> l2 = range(3)
> '> for b in l1:
> '>     for i in l2:
> '>         a.append(i*2*b)
>
> Stephen




More information about the Python-list mailing list