Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 5)
5.
What will be the output of the following Python code?
x = [1, 2, 3]
y = x
y[0] = 10
print(x)
Answer: Option
Explanation:
Both
x
and y
reference the same list object. Therefore, modifying y
also modifies x
, resulting in the output [10, 2, 3]
.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers