Commit 3ebde28d authored by Ann Gledson's avatar Ann Gledson Committed by Lauren Ko

Update 04-lists.md (#763)

* Update 04-lists.md

I think it's good to repeat the explanation of behaviour caused by (attempted) copying and then modifying the list in place. From teaching this several times, I think it would help to notify the learner that the use of append here is a second, similar example to what we saw earlier with the salsa list.

* Update 04-lists.md

Replaced brackets with back-ticks and added comma.
parent c8c37673
......@@ -268,7 +268,7 @@ odds after reversing: [11, 7, 5, 3]
While modifying in place, it is useful to remember that Python treats lists in a slightly
counter-intuitive way.
If we make a list and (attempt to) copy it then modify in place, we can cause all sorts of trouble:
As we saw earlier, when we modified the `salsa` list item in-place, if we make a list, (attempt to) copy it and then modify this list, we can cause all sorts of trouble. This also applies to modifying the list using the above functions:
~~~
odds = [1, 3, 5, 7]
......@@ -286,7 +286,7 @@ odds: [1, 3, 5, 7, 2]
{: .output}
This is because Python stores a list in memory, and then can use multiple names to refer to the
same list. If all we want to do is copy a (simple) list, we can use the `list` function, so we do
same list. If all we want to do is copy a (simple) list, we can again use the `list` function, so we do
not modify a list we did not mean to:
~~~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment