Re: [Tutor] Append to list

2018-05-10 Thread Mats Wichmann
On 05/09/2018 11:56 AM, Rick Jaramillo wrote: > > Hello, > > I’m having trouble understanding the following behavior and would greatly > appreciate any insight. > > l = [1,2,3,4] > b=[] > > for i in range(l): > print l > b.append(l) > l.pop(0) > > print b You've had some other c

Re: [Tutor] Append to list

2018-05-09 Thread Steven D'Aprano
On Wed, May 09, 2018 at 10:56:45AM -0700, Rick Jaramillo wrote: > > Hello, > > I’m having trouble understanding the following behavior and would greatly > appreciate any insight. > > l = [1,2,3,4] > b=[] > > for i in range(l): That's not actually your code, is it? Because range(l) gives a T

Re: [Tutor] Append to list

2018-05-09 Thread Alan Gauld via Tutor
On 9 May 2018, at 23:57, Rick Jaramillo wrote: > >Hello, >I’m having trouble understanding the following behavior and would greatly >appreciate any insight. >l = [1,2,3,4] >b=[] >for i in range(l): >    print l >    b.append(l) >    l.pop(0) >print b >OUTPUT >[1,2,3,4] >[2,3,4] >[3,4] >[4] >