0

What is the function of del

23rd Apr 2019, 6:21 PM
Richard Lihaba
Richard Lihaba - avatar
2 Respuestas
+ 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
23rd Apr 2019, 6:45 PM
Lothar
Lothar - avatar
+ 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
23rd Apr 2019, 9:06 PM
Marcin Szcz
Marcin Szcz - avatar