Mar-19-2019, 10:25 AM
Hey Buran,
Super interesting article and it explained a lot to me. However I don't get a tiny thing: lists are mutable, okay. And therefor doing this:
But since lists are mutable I would expect that changing "start" to a new definition would alter the "new" list as well.
Why doesn't it output "test" a few times?
Super interesting article and it explained a lot to me. However I don't get a tiny thing: lists are mutable, okay. And therefor doing this:
start = [1,2,3,4,5] new = [] t = True for s in start: new.append(start) if t: start.pop(0) t = False print(new)"new" will output [2,3,4,5] a few times. As expected.
But since lists are mutable I would expect that changing "start" to a new definition would alter the "new" list as well.
start = [1,2,3,4,5] new = [] t = True for s in start: new.append(start) if t: start.pop(0) t = False start = ["test"] print(new)But python will still output [2,3,4,5] a few times.
Why doesn't it output "test" a few times?