Python List clear() MethodPython clear() method removes all the elements from the list. It clear the list completely and returns nothing. It does not require any parameter and returns no exception if the list is already empty. The syntax and examples are described below. SignatureParametersNo parameter ReturnIt returns None. Let's see some examples of clear() method to understand it's functionality. Python List clear() Method Example 1Let's see a simple example in which clear() method is used to clear a list. The clear() method clears all the elements from the list. Output: 1 2 3 After clearing: Python List clear() Method Example 2If the list is already empty, the method returns nothing. See the example below. Output: After clearing: Next TopicPython list count method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India