0
What is the function of del
2 Antworten
+ 3
hi Richard, del can be used to delete variables:
a = 17
print(a) # result 17
del a
print(a) # result error
But also elements of a list or a complete list can be deleted with del:
mylst = [1,2,3,4]
del mylst[3]
print(mylst) # result [1,2,3]
del mylst
print(mylst) # result error
+ 1
The purpose of deleting variables or elements of lists and so on is to free up space in memory...it becomes important when you are handling a lot of data or big (numpy) arrays or something like this