Easy Tutorial
❮ Python Func Number Log Python String Replace ❯

Python3 List clear() Method

Python3 List


Description

The clear() function is used to empty a list, similar to del a[:].

Syntax

Syntax for the clear() method:

list.clear()

Parameters

Return Value

This method does not return any value.

Example

The following example demonstrates the use of the clear() function:

#!/usr/bin/python3

list1 = ['Google', 'tutorialpro', 'Taobao', 'Baidu']
list1.clear()
print("List after clearing: ", list1)

The output of the above example is:

List after clearing:  []

Python3 List

❮ Python Func Number Log Python String Replace ❯