I am trying to delete a list within a list but my code is unable to do so even though I have deleted the list.
y = [45]
x = [1,2,3,5,y]
del y
print(x)
Output of printing x:
[1, 2, 3, 5, [45]]
My output shows as [1, 2, 3, 5, [45]]
which means list y
still exists in list x
.
But I deleted list y
in my code. Why is list y
still not deleted then? Is there something wrong with my code? How do I delete an entire list in Python?