Program - What happens "behind" the curtains is that the tuple is not modified, but a new object is generated every time, which will inherit the old "name tag":


Topic: Program - What happens "behind" the curtains is that the tuple is not modified, but a new object is generated every time, which will inherit the old "name tag":

Solution

my_tup = (1,)
print(id(my_tup))
my_tup += (4,)
print(id(my_tup))
my_tup = my_tup + (5,)
print(id(my_tup))



List all Python Programs