YouTip LogoYouTip

Python3 Att List Clear

# Python3.x Python3 List clear() Method [![Image 3: Python3 Lists](#) Python3 Lists](#) * * * ## Description The clear() function is used to empty a list, similar to **del a[:]**. ## Syntax The syntax for the clear() method is: list.clear() ## Parameters * None. ## Return Value This method does not return any value. ## Example The following example demonstrates the usage of the clear() function: ## Example #!/usr/bin/python3 list1 =['Google','Tutorial','Taobao','Baidu'] list1.clear() print("List after clearing: ", list1) The output of the above example is as follows: List after clearing: [] [![Image 4: Python3 Lists](#) Python3 Lists](#)
← Python3 Iterator GeneratorPython3 Att List Clear β†’