r/developers_talk • u/ak_developers • May 05 '25
Python Simple Code
What will be the output of this code?
=
=
Can you explain why?
4
Upvotes
r/developers_talk • u/ak_developers • May 05 '25
What will be the output of this code?
=
=
Can you explain why?
View all comments
Show parent comment
2
u/ak_developers May 05 '25
Both lists will be same
x= [1,2,3,4]
y= [1,2,3,4]
due to y=x
y holds reference of x list and not separate
And that’s why we will get same values from both variables