Are tuples really immutable in Python?

Asked

Viewed 51 times

1

t = (1,2,[4,6])

t is a tuple. If we do:

t[2][0]="e"

we shall have:

(1, 2, ['e', 6])

Now the tuple t is (1, 2, ['e', 6])

We didn’t change the tuple?

Be it s= "stackoverflow"

It is not possible to do, for example, s[0] = "p"

but we can do s = "stackoverflowpt"

We don’t change you?

What really means the immutable in Python?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.