"python3 attributeerror: 'list' object has no attribute 'clear'" Answer’s

0

list.clear was added in Python 3.3.

Citing the Mutable Sequence Types section in the documentation:

New in version 3.3: clear() and copy() methods.

s.clear() removes all items from s (same as del s[:])

See the issue #10516 for the relevant discussion and alternative ways of clearing lists. In summary, it is the same as del l[:] and l[:] = [].

Tuesday, August 10, 2021
 
job
answered 6 Months ago
job
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share