+ 2
In python Why is this :: symbol is used can anyone would like to explain me this
I have one program in which that symbol was used a=[5,10,15,20,25] del a[::2] print(a) And the output was [10, 20]
5 Respostas
+ 9
These are two separate colons.
a[start:stop:step]
Take this & the next lessons again:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2453/
+ 6
so in your sample the code means:
a=[5,10,15,20,25]
del a[::2]
delete every 2nd element, starting from 1st element up to the last element. 5, 15 and 25 will be deleted. 20 and 20 remains.
+ 4
can you show us the complete part / line of code. I estimate you mean this [::-1]?
+ 2
[::2] is list slicing
in that context it means removing every other element
list slicing has many aplocations... đ
+ 2
Actually i did reached uptil the list slicing đđ
Then to but i know understood the concept properly đđ.I won't forget.
thank guys for ur help