Is the following safe?
x = [1, 2, 3, 4] x = [y+5 for y in x]
Does the list comprehension first by creating a new list, and then assigns this new list x? I was once told that changing the list upon repeated execution is unsafe.
You do not change the list while iterating over it, you create a completely new list, and then, once it has been evaluated, you bind it to the name xso that everything is safe.
x
Yes, it is safe.
, , ( ) x. , , , .