Python Introducing Lists Using Lists Review Mutability

Mark Nembhard
Mark Nembhard
1,385 Points

Why are there so many copies in the taco joint question? It seems like the restaurants has been copied 3 times

I am looking at the code and it seems like the repetition is one two much

1 Answer

Steven Parker
Steven Parker
200,416 Points

There are two calls to "copy" in the example. The first creates "taco_joints" so it can be modified without affecting "restaurants", and the second one is for the loop to make sure the modification does not interfere with the iteration.

But you're right, the loop could have been based on "restaurants" instead of making another copy. Good eye!