What is the meaning of [:] in python [duplicate]

[:] is the array slice syntax for every element in the array.

This answer here goes more in depth of the general uses: Explain Python’s slice notation

del arr # Deletes the array itself
del arr[:]  # Deletes all the elements in the array
del arr[2]  # Deletes the second element in the array
del arr[1:]  # etc..

Leave a Comment

tech