Python‎ > ‎list‎ > ‎

list.clear()

http://www.adilwaseem.com/

Definition
Remove all items from L.

Syntax
L.clear() -> None

Parameters
None

Examples
The returns with:
 x=[222,333,444]
x.clear()
print(x)

>>>
[]

list.clear(decimal)
The method list the decimal value and limit the decimal point to '1.00' through quantize.
from decimal import Decimal
list1=list()
list.append((Decimal(2.10).copy_negate().quantize(Decimal('1.00')),
                                 Decimal(1.3).copy_sign(Decimal(1.3)).quantize(Decimal('1.00')),
                                    Decimal(3).exp().quantize(Decimal('1.00')))
)
print("The items in the list1 are:,", list1)

>>> 
The items in the list1 are:, [(Decimal('-2.10'), Decimal('1.30'), Decimal('20.09'))]
>>>
>>> list1.clear()
>>> list1
[]
>>>

Comments