Python3 List clear () method
description
clear () function is used to clear the list, similar todel a [:].
grammar
clear () method syntax:
list.clear()
parameter
- no.
return value
This method has no return value.
Examples
The following example shows the clear () function to use:
#!/usr/bin/python3 list1 = ['Google', 'w3big', 'Taobao', 'Baidu'] list1.clear() print ("列表清空后 : ", list1)
Examples of the above output results are as follows:
列表清空后 : []