Can someone help me in understanding this python puzzle?

Consider the following code:

X=(1,2,3) 
X[1]=4

 What is X?

Can someone help me in understanding this python puzzle?

Have you tried this? What result do you get?

1 Like

I reckon the question is not what, but why you get what you get. The reason is that unlike lists, tuples are immutable.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.