Question #880

What is the output of the code snippet below?
my_var = "Python"
id1 = id(my_var)
my_var += " rocks!"
id2 = id(my_var)
print(id1 == id2)

Whenever the += operator is used against a string, a new string is returned. (python-reference.readthedocs.io/en/latest/docs/operators/...)


Comment on Disqus:

Question difficulty: 🔵🔵🔵🔵🔵


Similar questions: