Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 37)
37.
What is the output of the following Python code?
x = [1, 2, 3]
y = x[:]
y[0] = 10
print(x)
Answer: Option
Explanation:
Slicing with [:] creates a new copy of the list, so modifying
y
does not affect x
.
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