del listx[i] del listx[start:end] del listx[start:end:step]
[dywang@deyu zzz]$ cat list8.py
#!/usr/bin/python3
# coding: utf-8
listx = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
print("listx =", listx)
del listx[3]
print("listx =", listx)
del listx[5:6]
print("listx =", listx)
del listx[2:8:2]
print("listx =", listx)
[dywang@deyu zzz]$ ./list8.py listx = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] listx = [1, 2, 3, 5, 6, 7, 8, 9, 0] listx = [1, 2, 3, 5, 6, 8, 9, 0] listx = [1, 2, 5, 8, 0]
[dywang@deyu zzz]$ cat list9.py
#!/usr/bin/python3
# coding: utf-8
listx = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
print("listx =", listx)
del listx
print("listx =", listx)
[dywang@deyu zzz]$ ./list9.py
listx = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
listx =
Traceback (most recent call last):
File "./list9.py", line 7, in <module>
print("listx = ", listx)
NameError: name 'listx' is not defined