0

I am trying to edit a list of lists by

s[0][0]=1

but instead of just the first number in the first row changing to 1, the first number in all the rows are changing to 1.

I was first taught python using 2.7, but the class I'm taking now requires 3.4. Was there a change in syntax between the two versions? Otherwise, what am I doing incorrectly?

Thanks in advance

  • I suspect you created your lists by multiplication: [Python list of lists, changes reflected across sublists unexpectedly](http://stackoverflow.com/q/240178) – Martijn Pieters Feb 01 '15 at 02:29
  • Did you use multiplication to build your list of lists? – bsoist Feb 01 '15 at 02:29
  • Most importantly, you created references to *the same list object* rather than new lists. You'll have to show us *how* you created those lists for us to be able to help any further. – Martijn Pieters Feb 01 '15 at 02:30
  • I did use multiplication to create my list. Thank you! – Elizabeth Bernabe Feb 01 '15 at 02:30
  • Aside: when asking a question, you should create a [self-contained working example](http://stackoverflow.com/help/mcve) to show the problem; while multiplication was a reasonable guess, there are other ways you could have produced the same effect (multiple references to a single list). – DSM Feb 01 '15 at 02:35

0 Answers0