+ 2
what is the out put of the following code?
a=[1,2,3] s=a[:]+a print(len(s))
5 Respostas
+ 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... :)
+ 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.
+ 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......
+ 3
s=a+a
s=([1,2,3,1,2,3])
Print (len. (s))
Output ->6
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???