copy() function in python by R4R Team

-copy() is a python in-build function which are applicable only on list ans set data tpye in python. and it copy the content of one sequence to another sequence.

Syntax-

seq.copy()

-Here seq will be list or set.


program-

l=[1,2,3]
l1=l.copy()
print(l1)

l1=["one","two","three"]
l1=l.copy()
print(l1)

s=set([4,5,6])
s1=s.copy()
print(s1)


output-

[1, 2, 3]
[1, 2, 3]
{4, 5, 6}


-In this program, we copy the items of one list into another, if second list contain some items then also it erase the content and copy new content.
- It is also work similar in case of set data type.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!