+ 2

what is the out put of the following code?

a=[1,2,3] s=a[:]+a print(len(s))

5th Jul 2020, 3:18 AM
Azad m. A.
Azad m. A. - avatar
5 Answers
+ 6
Az.A. a=[1,2,3] s=a[:]+a =>s=[1,2,3]+[1,2,3] =>s=[1,2,3,1,2,3] Therefore print(len(s)) =print(len([1,2,3,1,2,3])) =6 Hope you understand... :)
5th Jul 2020, 3:48 AM
Indira
Indira - avatar
+ 3
s will be a[:] + a So therefore: s = [1,2,3,1,2,3]. The length of s print(len.(s)) # above So the answer is the length of [1.2.3.1.2.3] -> 6.
5th Jul 2020, 4:32 AM
Nilesh
Nilesh - avatar
+ 3
a is [1,2,3] and s=a[:]+a # whenever starting any value is not given it takes the index [0] as starting and ending as the last value of list..... So, a[:] is same as a. Therefore, a=[1,2,3]=a[:] So on adding them, [1,2,3,1,2,3] which is stored in the variable"s"...... And on counting"s" there are 6 Numbers so, the output is 6......
5th Jul 2020, 5:05 AM
Arctic Fox
Arctic Fox - avatar
+ 3
s=a+a s=([1,2,3,1,2,3]) Print (len. (s)) Output ->6
6th Jul 2020, 2:13 AM
Rajab Shabbir
Rajab Shabbir - avatar
0
Any special usages of a[:] ?? as long as it is the same as ' a list ' . of course, not the same ID but except having a copy of it, any thing else is used for???
6th Jul 2020, 4:55 AM
Azad m. A.
Azad m. A. - avatar