So (x,y) = ( [[1,2,3]] , 5) at the beginning of the loop. So x = [[1,2,3]] So x.append ( [4,5,6] ) should change x to [[1,2,3],[4,5,6]] - right? And y+1 = 6
And then one is just redifining b[0] to be ( [[1,2,3],[4,5,6]] , 6 ) Right? On Friday, May 15, 2015 at 11:22:02 PM UTC-5, Nils Bruin wrote: > > On Friday, May 15, 2015 at 9:07:13 PM UTC-7, Phoenix wrote: >> >> What is wrong with this code? >> >> b = [] >> a = [1,2,3] >> b.append( ([a],5)) >> for (x,y) in b >> b[0] = (x.append([4,5,6]),y+1) >> > > Just step through the code: > > (x,y) = b[0] > > what does x.append([4,5,6]) return? What would (x.append([4,5,6]),y+1) > then be? > > I don't think there is anything wrong with the code in that it doesn't > generate an error. There may be a mismatch between what the code actually > does an what you expect it to do. But this can easily be solved by > carefully observing what the code does and then adjusting expectations (or > changing the code). > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
