From 3ebde28d67ee8184451c125352f414f5333b2a80 Mon Sep 17 00:00:00 2001 From: Ann Gledson Date: Mon, 16 Dec 2019 02:04:02 +0000 Subject: [PATCH] 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. --- _episodes/04-lists.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_episodes/04-lists.md b/_episodes/04-lists.md index 780628d..b8b32df 100644 --- a/_episodes/04-lists.md +++ b/_episodes/04-lists.md @@ -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: ~~~ -- GitLab