a=[1,2,3]
b=[4,5,6]
c=[]
d=[]
Whats the difference between these two statements?
c[:]=a
d=b[:]
But both gives the same result.
c is [1,2,3] and d is [4,5,6]
And is there any difference functionality wise?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
c[:] = ait means replace all the elements of c by elements of ad = b[:]means create a shallow copy of b and assign it to d , it is similar tod = list(b)