Python‎ > ‎list‎ > ‎

list.copy()

http://www.adilwaseem.com/

Definition
Create a shallow copy of list.

Syntax
L.copy() -> list

Parameters
None

Examples
The return is:
x=[222,333,444]
x.copy()
print(x)

>>> 
[222, 333, 444]
>>>

list.copy(decimal)
The method list the decimal value and limit the decimal point to '1.00' through quantize and than return the copy of the list1.
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
[(Decimal('-2.10'), Decimal('1.30'), Decimal('20.09'))]
>>> list1.copy()
[(Decimal('-2.10'), Decimal('1.30'), Decimal('20.09'))]
>>>
Comments