Re: question about subroutine
dn via Tutor <[email protected]>
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Organization | DWM |
| Message-ID | <[email protected]> |
On 24/09/2023 00.54, Emma Sweetland wrote: > I was wondering if someone could advise about what is going wrong with this subroutine. With some debugging prints, I know the problem is definitely on line 9 when new[row][column] is assigned a new value. That part is working but the problem is that it is also changing the corresponding value in grid which is the list from which new was originally copied (using append). This is happening despite the fact that new and grid have different addresses (ids) so I don't understand how a change to new is affecting grid. Any help gratefully received. Thank you. Regret to advise that this list will not accept attachments. Please copy-paste code into the email message (and ensure formatting). It sounds like a misunderstanding about how Python handles 'variables'. Instead of a specific area of memory, Python ids are pointers. Thus, different lists could still point to the same values. https://docs.python.org/3/library/copy.html -- Regards, =dn _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor