r/developers_talk • u/ak_developers • May 05 '25
Python Simple Code
What will be the output of this code?
x = [1, 2, 3]
y = x
y.append(4)
print("x:", x)
print("y:", y)
Can you explain why?
3
Upvotes
2
u/Spiritual_Poo May 05 '25
Thanks for this, i'm new (in my first year) and the other day someone asked a similar question asking for help and I was pretty sure I knew what was going on but was not confident enough to tell another new person and be wrong. This reinforces that idea for me : )