Question #881

What is the output of the code snippet below?
my_list = ["apple", "banana", "grapefruit"]
id1 = id(my_list)
my_list+= ["cherries"]
id2 = id(my_list)
print(id1 == id2)

Lists are mutable. As such, the += operator applied on a list doesn't return a new object. The list my_list is appended in place. (stackoverflow.com/questions/2347265/why-does-behave-unexp...)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵